Solved

Determine remainder when dividing in ASP

Posted on 2007-04-01
3
486 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now