>Subject: floats
>From: "Nicolas Raitman" <[EMAIL PROTECTED]>
>Date: Fri, 2 Feb 2001 00:49:11 -0300
>OK... I cannot believe that I am stuck with this. The situation is this. I
>have some strings and I want to convert them to floats or doubles in order
>to sum all of them and then turn the result again to string so that I can
>show it. The problem is that I cannot do it... please... I am really
>stuck... those of you who already know it, please help. I just want to get a
>number like 2343.33, only 2 decimal places... how can I do this?
Sounds to me like you adding monetary values together.
If so, don't use floats! Use longs with two implied decimal
places and write your own conversion routines to convert to
and from long and currency.
The problem with floats is you get rounding errors.
1.01 + 1.01 + 1.01 may not add to 3.03
and people just don't understand it! They think the computer
can add.
I've always successfully avoided using floats (and doubles) because
I write applications for commercial applications. These representations
are vital for scientific and engineering apps, but poison for
commercial apps.
Roger Stringer
Marietta Systems, Inc.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/