• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 570
  • Last Modified:

Determine remainder when dividing in ASP

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
rcmb
Asked:
rcmb
1 Solution
 
Lee SavidgeCommented:
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
 
cupCommented:
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
 
rcmbAuthor Commented:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now