Hello,

I have run these tests on PalmOS 3.1H3 on a Visor:

Directly after a reset, _f_itof( 33554434) returns 0x4c000000,
_f_itof(33554435) returns 0x4c000001, _f_itof(-33554434) returns 0xcc000000,
_f_itof(-33554435) returns 0xcc000001. (The chosen inputs are 26 bit values, so
the low two bits will not fit in a 24-bit float and must be rounded. The
numbers that end in 10 were rounded toward zero, those ending 11 were rounded
away from zero. Consistent with round-to-nearest mode. So far so good.

After _fp_round(flpTowardZero):

The returns from _f_itof (same values) are 0x4c000000, 0x4c000000, 0xcc000000,
0xcc000000. All rounded toward zero.  Still so far so good.

After _fp_round(flpUpward):

The returns are 0x4c000001, 0x4c000001, 0xcc000000, 0xcc000000. The positive
ones rounded away from zero (up) and the negative ones toward zero (up). Still
good.

After _fp_round(flpDownward):

The returns are 0x4c000001, 0x4c000001, 0xcc000000, 0xcc000000--the same
as flpUpward. OOPS!

That's not all: now after _fp_round(flpToNearest) or _fp_round(flpTowardZero)--
both of which worked before--the results will still be as for flpUpward.  It is
as if flpUpward mode is sticky.  A reset will restore flpToNearest mode.  Also,
_fp_round(flpDownward) gives upward mode even if it is the first _fp_round call
after a reset.  There is no way to get downward mode.

Finally, the return value from _fp_round is not as documented in the FloatMgr.h
file comments (3.5 SDK). The comments say it returns the masked, two-bit value
passed in. What it really returns is that value leftshifted 4 places.  Somebody
knew about that because the constants flpModeMask and flpModeShift are defined
accordingly, but the behavior is contrary to the comments and also to the
M*CORE sfpe docs for _fp_round.

What gives?  Is there a fix or workaround?  How can a person select Downward
mode, and how can a person get back to Nearest or TowardZero without a reset?

Thanks,
Chapman Flack
[EMAIL PROTECTED]






-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to