PDA

View Full Version : Problem with FloatMath



VG
01-23-2009, 12:07 PM
Hi All,
·· I am having this weird problem:


VAR
·· long· Temp, Temp2, SpeedB, SpeedA

OBJ
··· FA : "FloatMath"

PUB x
.......
SpeedB = 100
SpeedA := Fa.FMul(SpeedB,Fa.FDiv(Temp2,Temp))
.......

When·Temp2 > Temp SpeedA has·correct values, around 100.
When Temp2 < Temp SpeedA is having values close to 10,000. It seems the value is multiplied by 10. Why and How???· I did not change FloatMath.

Sincerely,
VG

mirror
01-23-2009, 12:56 PM
This one comes up quite often, and has 2 solutions:

1) SpeedB := 100.0 'Make SpeedB a compile time floating point value.

-or-

2) Do integer to float conversion at run time:
SpeedA := Fa.FMul(Fa.FFloat(SpeedB),Fa.FDiv(Temp2,Temp))

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔