Jump to content
Sign in to follow this  
Linux

Error in calc, 1 Line example

Recommended Posts

Linux

if (4.02 - 4 <> 3.02 - 3) Then ConsoleWrite("4.02 - 4 = " & (4.02 - 4) )

I think it i dont need to say anything more.

how can 4.02 - 4 <> 0.02?

Post you comments.

Respect, Linux

@moderator, I couldn post this in bug section. if you fell like this belongs there, pls move it


You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!"

Share this post


Link to post
Share on other sites
weaponx

4.02 - 4 is coming out as 0.0199999999999996

Edited by weaponx

Share this post


Link to post
Share on other sites
PsaltyDS

Why? Shouln'd be 0.02?

It is, within the tolerance of a Double Word Floating Point number. You have the correct answer to within the tolerance of that number format. If it bothers you, round it to one less decimal place:

$a = 4.02 - 4
ConsoleWrite("Debug:  $a = " & $a & @LF)
$a = Round($a, 14)
ConsoleWrite("Debug:  $a = " & $a & @LF)
$b = 3.02 - 3
ConsoleWrite("Debug:  $b = " & $b & @LF)

:D

Edited by PsaltyDS

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  

×