News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

local float variable weirdness

Started by monkeybot, August 18, 2013, 04:46:46 AM

Previous topic - Next topic

monkeybot

local fraction#=360/100
#print fraction#
waitkey

using 1.64o when i compile this i get 3.0 not 3.6?

also constants are not being shown in the debugger.

am i being stupid?






bmorris

I got the same result, but then I ran this:

fraction# = 360.0/100.0
print fraction#
swapscreen
waitkey


This prints 3.6. It would appear that PB performs number-divisions using the "type" of the numbers themselves, so for floats, you need to include a decimal place to let it know that you want a float back.

(The "local" aspect seems to have no effect.)

monkeybot

ahha!
nice one,that was doing my head in,it seems strange that hasn't affected me before.

Thanks!

kevin

#3
 Seems there's an FAQ on such subjects.. :)  Variables & Math Questions



- PlayBASIC FAQ's