Solved

# Determine remainder when dividing in ASP

Posted on 2007-04-01
486 Views
When dividing a number in ASP I need to get the answer as a remainder vice a decimal. For instance if you divide 6 by 5 you get the answer of 1.2 where I need the answer to be 1 remainder 1. If there any way to do this in vbscript.

Thanks in advance for you help,
Curtis
0
Question by:rcmb

LVL 25

Accepted Solution

Lee Savidge earned 500 total points
Hi,

Best thing to do here is do 2 calculations. Firstly, do an integer division to get the integer portion, for example:

6\5 (rather than 6/5)

Then use the Mod() function to get the remainder:

6 mod 5

I know this is 2 calculations but unless you're doing a time critical application or millions of calculations, this is probably the simplest option.

Regards,

Lee
0

LVL 11

Expert Comment

Note that mod in vbscript  (and all the programming languages I have ever used)  is not the proper mathematical mod if you are playing with negative numbers.  It will give you the remainder when divided but not the modulus.
0

LVL 12

Author Comment

Lee, Thanks so much for helping. I have built some online flash cards for my children's school's website and I have addition, multiplication and subtraction working great but could not figure out the division. Nothing time sensitive here so this works great.

Curtis
0

## Featured Post

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…