BALA Posted February 2, 2007 Posted February 2, 2007 (edited) How can I check if the number produced after finding the square root of a number is a whole number? Edited February 2, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Moderators SmOke_N Posted February 2, 2007 Moderators Posted February 2, 2007 If IsInt()? $a = '3' $b = '3.2' If IsInt(Number($a)) Then MsgBox(0, 1, $a) If IsInt(Number($B)) Then MsgBox(0, 2, $B)Back to the help file for you... Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
DaleHohm Posted February 2, 2007 Posted February 2, 2007 IsInt() works in AutoIt becasue it does not use typed variables, but rather variants that use heuristics (hints from the data itself) to determine data-type. In other languages (and if AutoIt too if you want to) you would use the Mod function e.g. If Mod($number, 1) = 0 Then ; it's a whole number Else ; not a whole number EndIf Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble
BALA Posted February 2, 2007 Author Posted February 2, 2007 (edited) SmOke_N said: If IsInt()? $a = '3' $b = '3.2' If IsInt(Number($a)) Then MsgBox(0, 1, $a) If IsInt(Number($B)) Then MsgBox(0, 2, $B)Back to the help file for you... I didn't think of searching for "integer" since integers contain the set of negative numbers, but i guess in AutoIt they're interchangeable with Whole numbers. Well thanks then. EDIT: strike that about them being interchangeable, it returns 1 for negatives. Edited February 2, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
BALA Posted February 2, 2007 Author Posted February 2, 2007 DaleHohm said: IsInt() works in AutoIt becasue it does not use typed variables, but rather variants that use heuristics (hints from the data itself) to determine data-type. In other languages (and if AutoIt too if you want to) you would use the Mod function e.g. If Mod($number, 1) = 0 Then ; it's a whole number Else ; not a whole number EndIf Dale Sorry, I'm not familiar with modulus operation, what exactly is Mod() doing? [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Moderators SmOke_N Posted February 2, 2007 Moderators Posted February 2, 2007 DaleHohm said: IsInt() works in AutoIt becasue it does not use typed variables, but rather variants that use heuristics (hints from the data itself) to determine data-type. In other languages (and if AutoIt too if you want to) you would use the Mod function e.g. If Mod($number, 1) = 0 Then ; it's a whole number Else ; not a whole number EndIf DaleI do that every time someone asks this question, and you are always right there to show the "proper" way. The funny thing is, in my own code (a tad more thought put into it obviously, I use MOD myself). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
DaleHohm Posted February 2, 2007 Posted February 2, 2007 Ha! Not really trying to one-up you -- I had just started writing a reply when I noticed you had already chimed in.@bala - many sources... see Wikipedia - Modulo OperationDale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble
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