Oxygen Basic
Programming => Problems & Solutions => Topic started by: Mike Lobanovsky on April 25, 2014, 10:16:00 PM
-
1. Why does the following:
int VSYNC = 0
.....................
VSYNC++
print VSYNC
in the context of OpenglSceneFrame.inc print the following:
0.9999999997
to the console? The same happens with concatenation:
print "VSYNC=" + VSYNC
that yields
VSYNC=0.9999999997
yet equality tests like if VSYNC=1 then do pass correctly?
2. What are the usual methods of basic data type conversion (casting) in OxygenBasic? Anything like VB6's CInt()/CSng()/CDbl()/etc. or similar?
Thanks in advance,
-
Hi Mike,
I've come across this behaviour before, when some OS call leaves the FPU in a peculiar state. This affects the conversion of numbers to text.
The solution is to place finit after the offending OS calls, usually after setting tcontext / creating fonts, a one-time finit is sufficient.
-
Oh yeah,
I remember that finit in your message loop and I was wondering what it's there for... The funny thing is that I did leave it in its place seeing that it may actually be executed there because none of the messages processed in it did actually return prematurely except the trailing case else with a DefWindowProc() call in it.
And since my new VSYNC++ was executed in the same loop under case WM_MBUTTONUP (you've already used all other alternatives there leaving me with almost nothing for my own program interaction ;) ) above the trailing finit, it didn't naturally work to correct my int's.
Er, still what about OxygenBasic type casts, please?
-
Sorry Mike, Oxygen casts like C:
Example:
float f=(float) *a
Another alternative in the most recent release:
float f=cast(float) *a
-
Thanks again Charles,
That looks perfect for my purposes.