Page 1 of 1

OpenWindowedScreen and double addition

Posted: Sat Jan 15, 2011 1:44 am
by HienTau
Hi,

Either it's too late :shock: or there's something strange going on in this piece of code:

Code: Select all

t.d = 0
x1.d = t + ParseDate("%yyyy/%mm/%dd %hh:%ii:%ss", "2021/01/01 17:02:01")
x2.d = ParseDate("%yyyy/%mm/%dd %hh:%ii:%ss", "2021/01/01 17:02:02")
x3.s = FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", x1)
x4.s = FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", x2)

InitKeyboard()
InitSprite()

OpenWindow(0, 0, 0, 300, 200, "Test", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 300, 200, 0, 0, 0)

u.d = 0
xx1.d = u + ParseDate("%yyyy/%mm/%dd %hh:%ii:%ss", "2021/01/01 17:02:01")
xx2.d = ParseDate("%yyyy/%mm/%dd %hh:%ii:%ss", "2021/01/01 17:02:02")
xx3.s = FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", xx1)
xx4.s = FormatDate("%yyyy/%mm/%dd %hh:%ii:%ss", xx2)

Repeat
  ExamineKeyboard()
Until KeyboardReleased(#PB_Key_Escape)
For some reason x1 is not equal to xx1, although it should be. It seems to be related to OpenWindowedScreen, because if you put the calculations all in front of the call the results are correct. Any ideas?

Re: OpenWindowedScreen and double addition

Posted: Sat Jan 15, 2011 2:47 am
by IdeasVacuum
...Hmm, smells like a bug - xx1 is consistently 51 secs out, but why do you need a double? The results are intended to be integers and if you swap-out your doubles for integers, all is correct.

Re: OpenWindowedScreen and double addition

Posted: Sat Jan 15, 2011 3:52 am
by HienTau
Thanks for the reply, IdeasVacuum.

The example I posted is actually part of a larger piece of software for plotting data on screen. I need floating point numbers to store other types of dates, but using your hint I can at least work around the issue. 8)

Re: OpenWindowedScreen and double addition

Posted: Sat Jan 15, 2011 4:30 am
by netmaestro
Looks like a bug to me.

Re: OpenWindowedScreen and double addition

Posted: Sat Jan 15, 2011 12:55 pm
by HienTau
I opened a bug report topic. Thanks for checking the code :D