Oxygen Basic

Programming => Example Code => Topic started by: Peter on November 24, 2010, 05:11:19 PM

Title: Can be a Bug
Post by: Peter on November 24, 2010, 05:11:19 PM
Deleted
Title: Re: Can be a Bug
Post by: Charles Pegge on November 24, 2010, 09:36:47 PM

Hi Peter,

I get 11.999999999.. instead of 12

The normal rounding behaviour of the FPU is disrupted for some reason. I think it happens during GLUT initialisation - probably during the course of initialising fonts, where I have encountered this problem before.

It is fixed by inserting a finit instruction after binding GLUT

Charles

Code: [Select]
Bind glut32
(
  glutCreateWindow    glutCreateWindow
  glutKeyboardFunc    glutKeyboardFunc
  glutDisplayFunc     glutDisplayFunc
  glutFullScreen      glutFullScreen
  glutMainLoop        glutMainLoop
  glutBitmapCharacter glutBitmapCharacter
)
finit
Title: Re: Can be a Bug
Post by: Charles Pegge on November 25, 2010, 05:16:25 AM

Hi Peter,

If you make Number Single rather than long, you will get the expected behaviour.

(Autoconversion from single to long rounds fractional values to the nearest integer  )

Charles

Code: [Select]
Dim Num(4),Number as single
Dim a, as long
Num(1) = 12.8   
Num(2) = 15.9   
Num(3) = 18.7   
Num(4) = 20.6

for a=1 to 4
Number = Num(a)
print "Number" + str(a) + "  "  + str(trunc(Number))
next
Title: Re: Can be a Bug
Post by: Charles Pegge on November 25, 2010, 11:57:15 AM

Thank you Peter!

This is new to me.

Code: [Select]

xRet = GetWindowLong hwnd, GWL_EXSTYLE
xRet = xRet Or WS_EX_LAYERED
SetWindowLong hwnd, -20, xRet
SetLayeredWindowAttributes, hwnd, 0, 128, LWA_ALPHA


Charles