Jump to content

Getting remainder from a division problem.


 Share

Recommended Posts

I'm writing a small bit of code for a large project. What it does, is gets the remainder left over from a division problem... for example 223/200 and it will give you 23. I wrote a working program... but if I use large numbers it fails... e.g. 4561698 .It seems to fail on $calc3 = $calc1 - $calc2. I see no logical reason why it's doing this... So thanks in advance for any help.

$input = InputBox("Input a random number", "Input any random number")
$input2 = InputBox("Input the number to divide it by", "Input any number to divide it by")
If $input < $input2 Then
MsgBox(0, "Cannot divide", "This program cannot calculate this remainder")
Exit
EndIf
$calc1 = $input / $input2
$calc2 = Int($calc1)
$calc3 = $calc1 - $calc2
$calc3 = $calc3 * $input2
MsgBox(0, "Result", $calc3)
Link to comment
Share on other sites

Ah... I see, I couldn't find it when I was looking through the help file :) I guess I need to learn how to look harder.

There are times when given all the information, we're right back at square one, wondering where to look. I find myself there again from time to time.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...