Author Topic: help with print and/or type casting  (Read 2049 times)

0 Members and 1 Guest are viewing this topic.

Mike Lobanovsky

  • Guest
help with print and/or type casting
« on: April 25, 2014, 10:16:00 PM »
1. Why does the following:

Code: [Select]
int VSYNC = 0
.....................
VSYNC++
print VSYNC

in the context of OpenglSceneFrame.inc print the following:

Code: [Select]
0.9999999997
to the console? The same happens with concatenation:

Code: [Select]
print "VSYNC=" + VSYNC
that yields

Code: [Select]
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,

Charles Pegge

  • Guest
Re: help with print and/or type casting
« Reply #1 on: April 25, 2014, 10:39:25 PM »
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.
« Last Edit: April 26, 2014, 12:22:54 AM by Charles Pegge »

Mike Lobanovsky

  • Guest
Re: help with print and/or type casting
« Reply #2 on: April 25, 2014, 11:14:55 PM »
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?

Charles Pegge

  • Guest
Re: help with print and/or type casting
« Reply #3 on: April 25, 2014, 11:56:26 PM »
Sorry Mike, Oxygen  casts like C:

Example:

float f=(float) *a


Another alternative in the most recent release:

float f=cast(float) *a


Mike Lobanovsky

  • Guest
Re: help with print and/or type casting
« Reply #4 on: April 26, 2014, 12:15:29 AM »
Thanks again Charles,

That looks perfect for my purposes.