forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Division Resulting in Whole Number

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
ramjet
Newbie


Joined: 03 Jun 2003
Posts: 4

PostPosted: Wed Dec 08, 2004 8:11 pm    Post subject: Division Resulting in Whole Number Reply with quote

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
View user's profile Send private message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Wed Dec 08, 2004 8:17 pm    Post subject: Reply with quote

Is this of any use to you Ramjet? Smile

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

Ps. I removed your post in the "Bugs report" forum... Smile

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
ramjet
Newbie


Joined: 03 Jun 2003
Posts: 4

PostPosted: Wed Dec 08, 2004 8:24 pm    Post subject: Thanks Much. Reply with quote

Thanks much.

I'll give it a try and let you know how it goes.
Back to top
View user's profile Send private message
ramjet
Newbie


Joined: 03 Jun 2003
Posts: 4

PostPosted: Wed Dec 08, 2004 8:30 pm    Post subject: Works! Reply with quote

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
View user's profile Send private message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Thu Dec 09, 2004 9:05 am    Post subject: Reply with quote

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
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Fri Dec 10, 2004 7:56 am    Post subject: Reply with quote

or still another one Smile

Code:
if @equal(@frac(@fdiv(%%number,50)),0)
warn divisible!
end


serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Fri Dec 10, 2004 8:24 am    Post subject: Reply with quote

And another one? Smile

Code:
  if @pos(".",@fdiv(%%Number,50))
    warn divisible!
  end


Edit: seems not to work if the user has another decimal seperator on his OS than a dot... Embarassed

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Fri Dec 10, 2004 9:10 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
ramjet
Newbie


Joined: 03 Jun 2003
Posts: 4

PostPosted: Wed Dec 15, 2004 9:20 pm    Post subject: Many Thanks Reply with quote

Man...you all have certainly covered the options for me.

Many thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group