Fraction function

BlitzMax Forums/BlitzMax Beginners Area/Fraction function

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hello,

I need to know the fraction of a float (or double). So I tried
Function fraction:Double(f:Double) 
	Return f - Int(f) 
End Function

and I tried:
Function fraction:Double(f:Double) 
	Return f - Floor(f) 
End Function


This is what happens:
print fraction(1.2)
output > 0.20000004768371582

or this:
print fraction(1.93)
output > 0.92999994754791260


This is wrong (of course) and not accurate enough. Anyone an idea?

[edit]
Whoaah? What's this?
Just for a test I tried
Print 1.2 - 1.0
Print 1.2
output:
0.200000048
1.20000005
It looks like it's a rounding thing for the print-function, isn't it?
So, in that case, there is nothing wrong with the function. Whew!