;/*** ;*ceil.a - ;* ;* Copyright (c) 1991-91, Microsoft Corporation ;* ;*Purpose: ;* ;* ;*Revision History: ;* ;* 05-12-92 PLM written ;*/ ; ;/*** ;*double ceil(double x) - round to next highest integer ;* ;*Purpose: ;* Round to integer according to next highest integer. ;* ;*Entry: ;* ;*Exit: ;* ;*Exceptions: ;*******************************************************************************/ ; ; ;double ceil(double x) #include #include #include cProc _CIceil,PUBLIC localD fpstat cBegin _CIceil #ifdef SANE movem.l , -(a7) 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 move.l a0, -(a7) move.w #FORTI,-(a7) FP68K ;round result move.w d0,fpstat ;restore control word pea fpstat move.w #FOPROCEXIT,-(a7) FP68K movem.l (a7)+, #else fmove.l fpcr,d0 ;save current control word 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 fp0 ;round it up endif fmove.l d0,fpcr ;restore control word #endif cEnd _CIceil