double trouble

I have this strange behavior with a double var, see this example:

[code] dim d as Double

d = 1/10 'd = 0.1

if d < 0.5 then
MsgBox(“d < 0.5”)
end[/code]

The Message Box never appears. Can anyone explain this? I mean that d = 0.1, and 0.1 < 0.5 = True

It works for me with:

[code] dim d as double

d = 1/10

if d < 0.5 then
msgbox “bla”
end if[/code]

So I have no idea. Maybe something is blocking your MsgBox? Or maybe you haven’t restarted Xojo in a while?

Your exact code from your first message works fine and displays the message box for me using 2012 r2.1…

Sorry, I forgot to say that I’m using 2013r4.1. I know that it worked with older versions (at least all prior Xojo).

The original code works on 2013 4.1 on Windows 8.1. I put the code in a pushbutton.action event. Maybe try the following code to make sure that the event is firing:

[code]MsgBox(“Starting code”)
dim d as Double

d = 1/10 'd = 0.1

if d < 0.5 then
MsgBox(“d < 0.5”)
end[/code]

If you don’t see ‘Starting code’ when you run the program, then the code is not being executed. :slight_smile:

You could also put a break at the if to see what d actually is if/when it gets there.

Meanwhile I discovered that my code example doesn’t work on Windows 8.1. On Windows 7 it works as expected. Is anyone running Windows 8.1 Pro 64 Bit and can reproduce this?

[quote=64704:@Eugene Dakin]The original code works on 2013 4.1 on Windows 8.1. I put the code in a pushbutton.action event. Maybe try the following code to make sure that the event is firing:

[code]MsgBox(“Starting code”)
dim d as Double

d = 1/10 'd = 0.1

if d < 0.5 then
MsgBox(“d < 0.5”)
end[/code]

If you don’t see ‘Starting code’ when you run the program, then the code is not being executed. :)[/quote]

Hi Eugine
are you using Windows 8.1 64 Bit or 32 Bit?

With Win 8.1 - 64 Pro works ok here.

…hmm, I really have no further idea. I think Rolf is using Win 8.1 with German locale settings? Same as me.
The code is correct, because it works on my Windows 7 machine. So what could be the problem?

Hi Dierk,

Yes, the code was tested on two computers running Windows 8.1 64 bit with Xojo 2014 r4.1. Both computers provided the correct output. Both computers are set to English.

Just to shake things up, what happens if you do:
d = 1.0/10

or

d = 0.1

And have you set a breakpoint to see what d actually is at the if statement?

Of course I did. The problem seems to be my machine, but I have absolute no idea what it could be. The only thing I know is that I don’t have this problem with Windows 7, only with 8.1.

Beside Xojo I have NetBeans, QT Creator and Visual Studio Express 2012 on this machine, but thats on the Windows 7 one as well.

As work around I changed all my code were I’m working with double values (i.e. changed x = 0.5 in x = 5/10 etc.)

So what is d? Is the problem with the value or the comparison?