check multiple of 0.5

# Thread: check multiple of 0.5

1. Senior Member
Join Date
Dec 1969
Posts
226

## check multiple of 0.5

Hi, I want to check if a value inputted is a multiple of 0.5... I know I should use the mod function and check if the mod value is 0 or not. Since the error "divided by zero" will be occured if I try to mod a value with 0.5, therefore I multify the inputted value with 10 then mod by 5 should give me the answer. However, if the inputted value is 31.05, I will have the mod value equal to 0 as well. Anyone have suggestions on my problem? Thanks.

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## Working WAY too hard

If Int(num * 2) = num * 2 Then<BR> Response.Write "num is a multiple of 0.5"<BR>Else<BR> Response.Write "num is some odd fraction"<BR>End If<BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
226

## RE: Working WAY too hard

yes, thanks!<BR>I wrote a while loop for checking but yours is much easier and better...<BR><BR>iCount = 1<BR>do while 1<BR> dChkValue = iCount * cdbl(0.5)<BR> if dChkValue = cdbl(sValue) then<BR> exit do<BR> elseif dChkValue &#062; cdbl(sValue) then<BR> bValueValueErr = true<BR> exit do<BR> end if<BR> iCount = iCount + 1<BR>loop<BR>

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## That loop could take...

...a very very long time to run if you had a number such as <BR> 3.1E+112<BR><BR>(That&#039;s a 3 followed by 112 zeroes. Yes, that&#039;s a legal number.)<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•