>Subject: Floating point problem
>From: "Mahesh Salian" <[EMAIL PROTECTED]>
>Date: Tue, 23 Apr 2002 11:07:00 +0530
>
>I am using Code warrior IDE with C compiler.
>Can i use float in the data structure . Is it possible to pack and unpack
>this structure if i use float.
>The flat files which i sync with my application  hv the decimal digits (for
>eg. Price = 10.55 ). Can anybody suggest how could i capture this decimal
>numbers in my structure and also able to pack it.

As a generic design concept, using float to do arithmatic on 
prices is undesirable.  You are better off implementing non-float
arithmetic using assumed decimal places.
Users just don't understand when 1000 units at $49.99
calculates to $49989.99
You are much better off converting $49.99 to 4999, multiplying
by 1000 to 4999000 and then re-inserting the decimal point
reformatting the numeric string to the perfect answer of $49990.00

Roger Stringer
Marietta Systems, Inc.


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

Reply via email to