From: Jesus Calvino-F. <Je...@ec...> - 2005-06-07 16:52:52
|
I don't think that is the problem (if there is a problem), since the float typecast is promoting the constant 65536 to float before performing the operation. Take a look at the generated code below, where 65536 in fp format is 0x00, 0x00, 0x80, 0x47. Besides, I obtain the same results with sdcc and MSVC. ;C:/sdcc/tests/fp.c:17: result= 54.2535 * ((float) (I_HI) + (float) (F_HI) / 65536); ; genCall mov dpl,r2 push ar2 lcall ___uchar2fs mov r3,dpl mov r4,dph mov r5,b mov r6,a pop ar2 ; genIpush push ar2 ; Peephole 181 changed mov to clr clr a push acc ; Peephole 181 changed mov to clr clr a push acc mov a,#0x80 push acc mov a,#0x47 push acc ; genCall mov dpl,r3 mov dph,r4 mov b,r5 mov a,r6 lcall ___fsdiv At 06:23 AM 6/7/2005, you wrote: >result= 54.2535 * ((float) (I_HI) + (float) (F_HI) / 65536); > >65536 is taken as a signed integer constant by an ANSI compiler. > >On MS VC++ an integer is 32 bits. > >On SDCC an integer is 16 bits. > >It is correct that they produce different results. >But not what you intended. > >IMO SDCC should warn us that 65536 is out-of-range. >or if it chooses to implement it as 65536L . > >Ant |