Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INT() Problem in 5.2e - maybe?

Status
Not open for further replies.

aker

Programmer
Mar 27, 2002
52
US
Reading values from a Database with 4 decimal places, I want to print only the number of decimal places in use, eg

00123.0015 will print 123.0015
00456.1200 will print 456.12
00789.1230 will print 789.123

I tried using an IF THEN ELSE using a variable defined as
IsThousand := (QTD % INT(QTD) * 100) % INT(QTD % INT(QTD) * 100) <> 0

but it gives the wrong answer in the second part of the equation, eg. INT(59.1100 % INT(59.1100) * 100) = 10 (should be 11?).

(1) Is there another way to do this?
(2) Is there an error with the INT function?

Thanks in advance.
 
To add to this thread further, I believe the problem lies with the mathematical rounding problem incorporated into Clipper 5.2x, which David Husnian pointed out in:

&quot;Clipper and most computer languages use a binary floating point format for their real numbers. This causes precision errors which commonly show up in calculations, comparisons and when rounding. The problem is related to trying to represent an infinite number of decimal numbers into a fixed number (and a small fixed number at that) of binary bits. &quot;, as in the above example I was presented with the result 10.99 instead of 11.00.

He goes on to say &quot;CA-Clipper 5.3a is compiled and linked with the 8.0 release of Microsoft C, including the standard math library component. The rounding problems under this library are likely to be somewhat less severe.&quot;

I will now upgrade to 5.3a and see if the problem disappears.

Thanks for all you help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top