# Check if a square root is a whole number

## Recommended Posts

How can I check if the number produced after finding the square root of a number is a whole number?

Edited 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

##### Share on other sites

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.

##### Share on other sites

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

Automate input type=file (Related)

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

##### Share on other sites

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 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

##### Share on other sites

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

##### Share on other sites

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

I 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.

##### Share on other sites

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 Operation

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

Automate input type=file (Related)

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

## Create an account

Register a new account

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...