Author Topic: Can be a Bug  (Read 3122 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
Can be a Bug
« on: November 24, 2010, 05:11:19 PM »
Deleted
« Last Edit: April 14, 2015, 03:36:28 AM by Peter »

Charles Pegge

  • Guest
Re: Can be a Bug
« Reply #1 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

Charles Pegge

  • Guest
Re: Can be a Bug
« Reply #2 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

Charles Pegge

  • Guest
Re: Can be a Bug
« Reply #3 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