;/*** ;*ceill.a - ;* ;* Copyright (c) 1991-91, Microsoft Corporation ;* ;*Purpose: ;* ;* ;*Revision History: ;* ;* 06-03-92 XY based on ceil.a ;*/ ; ;/*** ;*long double ceill(long double x) - round to next highest integer ;* ;*Purpose: ;* Round to integer according to next highest integer. ;* ;*Entry: ;* ;*Exit: ;* ;*Exceptions: ;*******************************************************************************/ ; ; ;long double ceill(long double x) #include #include #include cProc ceill,PUBLIC parmT x localV xlocalx,10 localW xtestw localD fpstat cBegin ceill #ifdef SANE pea fpstat ;get current control word move.w #FOGETENV,-(a7) FP68K move.w fpstat,d0 ;save current control word move.w #IRC_UP,fpstat ;set sounding to up pea fpstat ;set new control word move.w #FOSETENV,-(a7) FP68K pea x move.w #FORTI,-(a7) FP68K ;round result move.w d0,fpstat ;restore control word lea x,a1 move.w (a1)+,d0 ;load result for return move.l (a1)+,d1 move.l (a1),a0 pea fpstat move.w #FOPROCEXIT,-(a7) FP68K #else fmove.l fpcr,d0 ;save current control word fmove.x x, fp0 ftst.x fp0 ;see if it is a valid number fmove.l fpsr, d1 ;get status word and.l #0x03007c00, d1 ;see if we get an exception cmp.l #0, d1 ifneq jbsr __Domain_error ; if not equal, domain error else fmove.l #IRC_UP,fpcr ;set rounding mode to up fint.x x,fp0 ;round it up endif fmove.l d0,fpcr ;restore control word #endif cEnd ceill