Sign in to follow this  
Followers 0
ForexGG

why this simple script gives me false not ture?

6 posts in this topic

$QUOTE_END = 161.10
$QUOTE_STA = 161.05

    $QUOTE_END -= 0.05
    MsgBox(0,"",$QUOTE_END & "  " & $QUOTE_STA,2)
    MsgBox(0,"",$QUOTE_END >= $QUOTE_STA,2)

isn't 161.05>=161.05?

why it gives false instead of ture?

thanks

Share this post


Link to post
Share on other sites



Even just = doesn't work. I guess it's some weirdness with how AutoIt habndles floating numbers, Rounding them works fine :

$QUOTE_END = 161.10
$QUOTE_STA = 161.05

    $QUOTE_END -= 0.05
    MsgBox(0,"",Round($QUOTE_END,2) & "  " & $QUOTE_STA)
    MsgBox(0,"",Round($QUOTE_END,2) >= $QUOTE_STA)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Try rounding to 2 decimal places.

MsgBox(0,"",Round($QUOTE_END,2) >= Round($QUOTE_STA,2),2)

Edited by picaxe

Share this post


Link to post
Share on other sites

thanks

must be a bug in Autoit

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

thanks

must be a bug in Autoit

It's not AutoIt, it's floating point precision. There many threads on these forums discussing this issue. Edited by picaxe

Share this post


Link to post
Share on other sites

thanks

must be a bug in Autoit

This is a standard behavior of floating point math on computers. It is correct to about 14 decimal places. AutoIt gets its math from the C++ libraries used to write and compile the interpreter.

:D


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0