[futurebasic] Re: [FB] math problem

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2007 : Group Archive : Group : All Groups

From: Ted Spencer <ted@...>
Date: Tue, 27 Feb 2007 13:22:27 -0500
On 27 Feb, 2007, at 1:12 PM, Douglas Stemen wrote:

> I just discovered (due to complaints from customers) that FB does  
> not seem to be handling some basic math correctly. Can someone tell  
> me why this following basic formula routine results in the long  
> integer y& having a value of 114 rather than 115. If x# is changed  
> to 1.13 or 1.14 the long integer is also wrong.
>
> dim x#,y&
> x#=1.15
> y&=100.00*x#
> stop str$(y&)
try:

dim x#, y&
x = 1.15
y = 100.00 * x
print y
print using "###.#################"; x,100*x

Note that you don't really have 1.15: you've got a little less  
because of binary arithmetic (not BCD). After multiplication, the  
result is an integer which chops off all decimal digits.

--
Ted
--
Never ruin an apology with an excuse.