473,388 Members | 1,340 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Need Help with Mathmatical Javascript statement

I am looking at a line of code in javascript that I dont understand...

var ad = n % nn;

What I dont understand is what the % represents as a mathmatical
function in javascript.

If anyone could explain what its doing, that would be great.

Thanks.

Mar 3 '06 #1
2 1147
Wyseguy79 wrote on 03 mrt 2006 in comp.lang.javascript:
I am looking at a line of code in javascript that I dont understand...

var ad = n % nn;

What I dont understand is what the % represents as a mathmatical
function in javascript.

If anyone could explain what its doing, that would be great.


read the specs:

result = number1 % number2

The modulus, or remainder, operator divides number1 by number2 and returns
only the remainder as result. The sign of result is the same as the sign of
number1. The value of result is between 0 and the absolute value of
number2.

For example, in the following expression, A (which is result) equals 5.6.

A = 19 % 6.7

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Mar 3 '06 #2

"Wyseguy79" <wy*******@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
I am looking at a line of code in javascript that I dont understand...

var ad = n % nn;

What I dont understand is what the % represents as a mathmatical
function in javascript.

If anyone could explain what its doing, that would be great.


It gives the reaminder after dividing n by nn.
10 % 3 returns 1, because when you divide 10 by 3 you get 3 - and a
remainder of 1.
Mar 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Johnny Knoxville | last post by:
I've added a favicon to my site (http://lazyape.filetap.com/) which works fine if you add the site to favourites the normal way, but I have some JavaScript code on a couple of pages with a link,...
8
by: Gilles T. | last post by:
How I can get element ID in the edit mode of datagrid control? If I not in the edit mode, there are no problem. <asp:TemplateColumn ItemStyle-CssClass="grid_column_width_3"...
1
by: Kevin Potter | last post by:
We have an application that has been running on IIS4 and IIS5 for quite some time, without problem We're now migrating to IIS6 (windows/2003), and have run into a what might? be a Javascipt...
2
by: Mike Button | last post by:
Hello all, I am really really desperate on what I should do, and I am asking for help from anyone in this newsgroup, here's the situation: I am creating a form that is being run on a server...
35
by: Boobie | last post by:
I need to escape HTML chracters so <test> --> &lt;test&gt; Looks like there is no built-in JS function...anyone got one handy ? thanks
13
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
22
by: the_grove_man | last post by:
I purchased a book titled "Pro ASP.NET 2.0" to get up to speed on web stuff because I ususally do Windows Form Applications.. But in the first chapters I was reading this week it brought to mind...
9
by: whitgurley | last post by:
I've searched the web as well as I can for a solution to this problem but have found nothing and just don't know enough about JavaScript to figure out what's going. What I'm trying to do is convert...
13
by: =?Utf-8?B?TWFyaw==?= | last post by:
Need help with a variable... This variable is used to keep track of permissions and can contain 1,2,4,8,16,32,64,128 Or it can contain a sum of one more of the above values. For example, if...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.