On Tue, Jan 22, 2002 at 09:08:52AM -0500, Dave Lippincott wrote:
> There is no Palm supported way to format decimal to a display format unless
> you can use scientific notation (and few do).  So it is best bet to write
> your own routine to convert a float or double to a string (you won't need
> the float library to do this).  Just use the regular float or double type
> for your variables and use your own formatting routine. Hint: you can search
> this forum's archive to get previously posted examples.

I'd also add that properly converting a floating point number to a
string representation is not that easy in general (especially if you
intend to write portable code).
I'd recommend to the interested reader the following paper:

 "How to Print Floating-Point Numbers Accurately"
   Guy L. Steele, Jr., Jon L. White
   Proceedings of the ACM SIGPLAN '90, pp. 92-101.

If you want a free-software, ready-to-use and portable implementation
(based on the above article), try to look at the dtoa() source code
in the FreeBSD libc sources. (It's is the code used by libc *printf()
family of function to print floating point values).

Cheers,
Marco

-- 
========================================================================
Marco Pantaleoni                                  [EMAIL PROTECTED]
Padova, Italy                                              [EMAIL PROTECTED]
elastiC language developer                   http://www.elasticworld.org

-- 
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