Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Determine remainder when dividing in ASP

Posted on 2007-04-01
3
Medium Priority
?
565 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Welcome, welcome!  If you are new to the series and haven't been following along, please take a brief moment to review the first three installments: Part 1 (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/A_266-VBScri…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

650 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