View Full Version : How to make the rest entire?

triko

11-23-2012, 01: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, 04: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, 07: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, 07: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, 11:03 PM

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

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

sunfighter

11-24-2012, 12:10 AM

hee hee, Guess it was.

Old Pedant

11-24-2012, 12:16 AM

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

triko

11-24-2012, 12:19 AM

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-24-2012, 12:22 AM

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-24-2012, 12:26 AM

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-24-2012, 12:48 AM

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.