OpenWindowedScreen and double addition

Just starting out? Need help? Post your questions and find answers here.
HienTau
User
User
Posts: 16
Joined: Thu Feb 24, 2005 9:31 am
Location: Bremen, Germany
Contact:

OpenWindowedScreen and double addition

Post 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?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: OpenWindowedScreen and double addition

Post 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.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
HienTau
User
User
Posts: 16
Joined: Thu Feb 24, 2005 9:31 am
Location: Bremen, Germany
Contact:

Re: OpenWindowedScreen and double addition

Post 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)
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: OpenWindowedScreen and double addition

Post by netmaestro »

Looks like a bug to me.
BERESHEIT
HienTau
User
User
Posts: 16
Joined: Thu Feb 24, 2005 9:31 am
Location: Bremen, Germany
Contact:

Re: OpenWindowedScreen and double addition

Post by HienTau »

I opened a bug report topic. Thanks for checking the code :D
Post Reply