Solved

Determine remainder when dividing in ASP

Posted on 2007-04-01
3
523 Views
Last Modified: 2008-02-20
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
Comment
Question by:rcmb
3 Comments
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 500 total points
ID: 18831681
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

by:cup
ID: 18832893
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

by:rcmb
ID: 18833225
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question