# Determine if an integer is divisible by

## Recommended Posts

Hey all,

I have an app which iterates a counter in an INI file on each run. I know the app runs every minute. I want to fire up a specific function if its the 10th minute. So the counter at that time would be 10, then 20 etc. There is no limit to how large the counter would go.

I am trying to figure out how I can determine whether counter is divisible by 10 with an integer as the result rather than a floating point.

Any suggestions?

Thanks.

##### Share on other sites

Hey all,

I have an app which iterates a counter in an INI file on each run. I know the app runs every minute. I want to fire up a specific function if its the 10th minute. So the counter at that time would be 10, then 20 etc. There is no limit to how large the counter would go.

I am trying to figure out how I can determine whether counter is divisible by 10 with an integer as the result rather than a floating point.

Any suggestions?

Thanks.

Can you devide the number by 10 and then use IsInt () to find out if the number is an integer?

EDIT Maybe I am not clear what you are trying to do - can you provide an example?

Edited by nitekram

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go."

"Everybody catches up with everyone, eventually"

"As you teach others, you are really teaching yourself."

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace \$ghGDIPDll with \$__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

# Ternary operator

##### Share on other sites

Hey all,

I have an app which iterates a counter in an INI file on each run. I know the app runs every minute. I want to fire up a specific function if its the 10th minute. So the counter at that time would be 10, then 20 etc. There is no limit to how large the counter would go.

I am trying to figure out how I can determine whether counter is divisible by 10 with an integer as the result rather than a floating point.

Any suggestions?

Thanks.

This is typically what the Mod function is used for. Mod returns the remainder of a division operation. So to do something every 10th time when your operation counter is \$i use:

If Mod( \$i, 10) = 0 Then
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

This is typically what the Mod function is used for. Mod returns the remainder of a division operation. So to do something every 10th time when your operation counter is \$i use:

If Mod( \$i, 10) = 0 Then
EndIf

Dale

That is so much shorter than my attemp - I always pick the hard way or the longest way.

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go."

"Everybody catches up with everyone, eventually"

"As you teach others, you are really teaching yourself."

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace \$ghGDIPDll with \$__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

# Ternary operator

##### Share on other sites

EDIT...beat me to it again. Maybe I should stop trying to help..lol

Edited by kjmarket
Pink Floyd - The Wall
##### Share on other sites

Thanks Dale and all for the help.

##### Share on other sites

• Moderators

If IsInt(\$i/\$x) Then
Should work as well.

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

If IsInt(\$i/\$x) Then
Should work as well.
True, in a language that uses variants like AutoIt does... but not in strongly-typed languages (where variables are declared as Int, Real etc)... Mod is a pretty universal, CS101, solution to the problem.

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

• Moderators

True, in a language that uses variants like AutoIt does... but not in strongly-typed languages (where variables are declared as Int, Real etc)... Mod is a pretty universal, CS101, solution to the problem.

Dale

Yeah, I definately see you're point now that I'm playing with 1 or 2 other languages at the moment.

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.

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...