View Full Version : How to make the rest entire?

triko

11-23-2012, 12:29 PM

Hi all guy!! I have problem begginer!!

In my equazion random ex: 140/26 = 5 rest 10.

How to do make my rest 10 and put in an a Variable? (in Javascript)?

function rest ()

{

var a = 140;

var b = 26;

var division = a / b; // 140 / 26 = 5 rest 10 :D

alert (division);

sunfighter

11-23-2012, 03:03 PM

<script type="text/javascript">

var a = 140;

var b = 26;

var division = Math.floor(a/b);

var reminder = a%b;

alert(division+" with a remember of "+reminder);

</script>

triko

11-23-2012, 06:41 PM

<script type="text/javascript">

var a = 140;

var b = 26;

var division = Math.floor(a/b);

var reminder = a%b;

alert(division+" with a remember of "+reminder);

</script>

Ei ! :D i'm test your code but the rest or remember isn't correct, i write 131 / 26

= 5 and rest 0, the code back me rest remember 1 ... :D

Can you explain me how to do the 1%b :D Thanks guy for your time!!

Philip M

11-23-2012, 06:56 PM

Ei ! :D i'm test your code but the rest or remember isn't correct, i write 131 / 26

= 5 and rest 0, the code back me rest remember 1 ... :D

Can you explain me how to do the 1%b :D Thanks guy for your time!!

Well, that is the correct answer!

<script type="text/javascript">

var a = 131;

var b = 26;

var division = Math.floor(a/b);

var remainder = a%b;

alert (division+" with a remainder of "+remainder); // 5 with a remainder of 1

</script>

Your English seems rather fractured. The word is remainder, not reminder or remember.

Old Pedant

11-23-2012, 10:03 PM

Actually, it was Sunfighter who used "remember" and "reminder" instead of "remainder".

Not sure they teach English in Missouri. <grin/>

sunfighter

11-23-2012, 11:10 PM

hee hee, Guess it was.

Old Pedant

11-23-2012, 11:16 PM

Hey, this is the JavaScript forum, not the English forum. You got the important part right. <grin/>

triko

11-23-2012, 11:19 PM

Well, that is the correct answer!

<script type="text/javascript">

var a = 131;

var b = 26;

var division = Math.floor(a/b);

var remainder = a%b;

alert (division+" with a remainder of "+remainder); // 5 with a remainder of 1

</script>

Your English seems rather fractured. The word is remainder, not reminder or remember.

No Philip I had copy the word by code of sunfighter!!!!

But, don't understand what is a%b :D

triko

11-23-2012, 11:22 PM

Hey, this is the JavaScript forum, not the English forum. You got the important part right. <grin/>

Thanks Pedant for clarification :) But, however the English it's more important for make oneself understood :D Infact my English , it's a little crap!!! no, more crap :D

Old Pedant

11-23-2012, 11:26 PM

a % b means *EXACTLY* "calculate the remainder when a is divided by b".

% is properly called the "modulo operator". What you called "rest" and we call "remainder" are both NOT correct mathematical terminology. "Modulo" is the correct terminology and % is indeed the modulo operator.

Incidentally, many languages use % as the modulo operator:

JavaScript

Java

C

C++

C#

PHP

and more.

triko

11-23-2012, 11:48 PM

a % b means *EXACTLY* "calculate the remainder when a is divided by b".

% is properly called the "modulo operator". What you called "rest" and we call "remainder" are both NOT correct mathematical terminology. "Modulo" is the correct terminology and % is indeed the modulo operator.

Incidentally, many languages use % as the modulo operator:

JavaScript

Java

C

C++

C#

PHP

and more.

An ok, so the name correct it's Modulo :D OK... however I had called "rest" because in Italian remainder is resto!

:D

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.