Kiti Posted December 29, 2009 Share Posted December 29, 2009 Hello! I've wrote this code, run it to see what it happens: $ET = 4567 $LS = 20 $LR = 9 $TE = 12 $NS = 23 $p = 1 For $i = 0 To 10 $x = ((Ceiling($ET / 1.1) * 1.1 - 1.1 * Int(20 * $LS * 1.1 ^ $LS) - 1.1 * Int($p * 30 * $LR * (1.05 + $TE * 0.01) ^ $LR))) / ($NS * 1.1) If IsInt($x) Then MsgBox(0, "","IF $p = " & $p & " then " & $x & " is integer") Else MsgBox(0, "","IF $p = " & $p & " then " & $x & " is NOT integer") EndIf $p = $p - 0.1 Next When $p is 0.8 $x is 25 but is NOT recognized as an integer. The message box says "IF $p = 0.8 then 25 in NOT integer". Why?? 25 IS an integer! How can I solve this? Thank you in advance! Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30 Link to comment Share on other sites More sharing options...
Mat Posted December 29, 2009 Share Posted December 29, 2009 Its becouse its a floating point number. The best way I found was to test: "StringInStr($x, ".")" And if you want to test if its a specified number: 'String($x) = "25"'. AutoIt Project Listing Link to comment Share on other sites More sharing options...
Kiti Posted December 29, 2009 Author Share Posted December 29, 2009 (edited) I don't know what number it will be, I just want to do something when it's an integer. The StringInStr test is great, thank you very much! And one more thing: At the 10th run, when $p should be 0, it displays it as 1.38777878078145e-016. Why is that? Is there any nicer approach than "If $i = 10 then $p = 0" ? Edited December 29, 2009 by Kiti Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30 Link to comment Share on other sites More sharing options...
Bowmore Posted December 29, 2009 Share Posted December 29, 2009 I don't know what number it will be, I just want to do something when it's an integer. The StringInStr test is great, thank you very much! And one more thing: At the 10th run, when $p should be 0, it displays it as 1.38777878078145e-016. Why is that? Is there any nicer approach than "If $i = 10 then $p = 0" ? This method should work for all numbers $ET = 4567 $LS = 20 $LR = 9 $TE = 12 $NS = 23 $p = 1 For $i = 0 To 10 $x = ((Ceiling($ET / 1.1) * 1.1 - 1.1 * Int(20 * $LS * 1.1 ^ $LS) - 1.1 * Int($p * 30 * $LR * (1.05 + $TE * 0.01) ^ $LR))) / ($NS * 1.1) If _ValueIsInt($x) Then MsgBox(0, "","IF $p = " & $p & " then " & $x & " is integer") Else MsgBox(0, "","IF $p = " & $p & " then " & $x & " is NOT integer") EndIf $p = $p - 0.1 Next Func _ValueIsInt($val) If (($val - Int($val)) < 0.00000000000001) Then Return True Else Return False EndIf EndFunc "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now