I think that I solved this...
From include file FP32.A18:
IeeFormat:Code:; 32 bit floating point representation ; EXPONENT 8 bit biased exponent ; It is important to note that the use of biased exponents produces ; a unique representation of a floating point 0, given by ; EXP = HIGHBYTE = MIDBYTE = LOWBYTE = 0x00, with 0 being ; the only number with EXP = 0. ; HIGHBYTE 8 bit most significant byte of fraction in sign-magnitude representation, ; with SIGN = MSB, implicit MSB = 1 and radix point to the right of MSB ; MIDBYTE 8 bit middle significant byte of sign-magnitude fraction ; LOWBYTE 8 bit least significant byte of sign-magnitude fraction ; EXPONENT HIGHBYTE MIDBYTE LOWBYTE ; xxxxxxxx S.xxxxxxx xxxxxxxx xxxxxxxx ; | ; RADIX ; POINT
http://www.h-schmidt.net/FloatConverter/IEEE754.html
As you can see in IEE format, only 7 bit of exponent is in first byte, so bit 23 should be shifted to first bit of byte3, when shifting to right exponent.
Here is binary for 23.75:
As you can see Darrel's code set sign instead of first bit of exponent.Code:IEE 41BE0000 = 01000001 10111110 00000000 00000000 MCHIP 833E0000 = 10000011 00111110 00000000 00000000 Darel 82BE0000 = 10000010 10111110 00000000 00000000
Here is my code, done in PBP
I'll try to fix Darrel's macro.Code:MyIEEEtoMCHIP: B.BYTE0=A.BYTE0 B.BYTE1=A.BYTE1 B.BYTE2=A.BYTE2 : B.23=A.31 'SIGN B.BYTE3=A.BYTE3<<1 : B.24=A.23 RETURN A-IEEE B-Microchip




Bookmarks