| View previous topic :: View next topic |
| Author |
Message |
ramjet Newbie

Joined: 03 Jun 2003 Posts: 4
|
Posted: Wed Dec 08, 2004 8:11 pm Post subject: Division Resulting in Whole Number |
|
|
All,
I'm hoping you can help with the logic because it's completely escaping me at this time.
I have a list with items in it and I'm wanting to trigger an event every time the list is divisible by a value resulting in a whole number.
For example, the value I'm working with is 50. So everytime the items in the list are divisible by 50 resulting in a whole number an event fires.
50 items - event fires
55 items - no event
100 items - event fires
133 items - no event
etc.
The limit could be a very large value so I'm hoping the logic will just rely upon a whole number being valid and nothing else. |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Wed Dec 08, 2004 8:17 pm Post subject: |
|
|
Is this of any use to you Ramjet?
| Code: | %%Number = 152
if @equal(@div(%%Number,50),@fdiv(%%Number,50))
info Divisible by 50!
end |
It uses both the @div() and @fdiv() function. The reason for this is that the first one will always return a formatted number, while the second will give a floating point number. Only if the actual answer doesn't have a point (and is divisible by 50), the @equal() will return true and the code will be executed...
Ps. I removed your post in the "Bugs report" forum...  _________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
ramjet Newbie

Joined: 03 Jun 2003 Posts: 4
|
Posted: Wed Dec 08, 2004 8:24 pm Post subject: Thanks Much. |
|
|
Thanks much.
I'll give it a try and let you know how it goes. |
|
| Back to top |
|
 |
ramjet Newbie

Joined: 03 Jun 2003 Posts: 4
|
Posted: Wed Dec 08, 2004 8:30 pm Post subject: Works! |
|
|
This works like a champ.
Thanks much fro your assistance and rapid response.
I'm sure I'll be back for more.
Cheers. |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Thu Dec 09, 2004 9:05 am Post subject: |
|
|
Or you can use:
if @zero(@mod(%%NUMBER,50))
info Divisible by 50!
end
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Fri Dec 10, 2004 7:56 am Post subject: |
|
|
or still another one
| Code: | if @equal(@frac(@fdiv(%%number,50)),0)
warn divisible!
end |
serge _________________
|
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Fri Dec 10, 2004 9:10 am Post subject: |
|
|
You can use option decimalsep to fix the separator to a dot. I always use this, otherwise any hard-coded constants don't work when the user has a different decimal separator either. _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
ramjet Newbie

Joined: 03 Jun 2003 Posts: 4
|
Posted: Wed Dec 15, 2004 9:20 pm Post subject: Many Thanks |
|
|
Man...you all have certainly covered the options for me.
Many thanks. |
|
| Back to top |
|
 |
|