473,246 Members | 1,356 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,246 software developers and data experts.

Maximum number

Hi,

What is the maximum number in JavaScript? I tried a large number like
0xff...ff with 30 fs, it still gives me a number, not an infinity. I
use IE6.

Thanks.
Jul 20 '05 #1
4 20736
ym*@kicon.com (chirs) writes:
What is the maximum number in JavaScript? I tried a large number like
0xff...ff with 30 fs, it still gives me a number, not an infinity. I
use IE6.


Javascript uses IEEE-754 double precission floating point numbers.
From the ECMAScript standard:
---
... of them are normalised, having the form
s m 2^e
where s is +1 or -1, m is a positive integer less than 2^53 but not less
than 2^52, and e is an integer ranging from -1074 to 971, inclusive.
---
That means that the maiximal number representable as a Javascript number
is
1 * (2^53-1) * 2^971 == 2^1024 - 2^971
In hexadecimal, that is:

0xfffffffffffff80000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000

(256 hexadecimal digits)

Writing that hexadecimal number into Javascript, makes it output this
notation:
1.7976931348623157e+308

If you add one more bit, changing the "8" to a "c" in the hexadecimal
notation, Javascript gives "Infinity". Only that bit matters, changing
later bits is simply ignored. That is

0xfffffffffffffbffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffffffffffffffffffffff ffffffff

gives the same result as the above, because all the extra one-bits are
lost due to lack of precission, and they are rounded down.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Thanks a lot for the message.

IEEE-754 double precission floating point numbers are 64 bits. But
how can it use 64 bit number field to store 256 hex digits?
Jul 20 '05 #3
ym*@kicon.com (chirs) writes:
Thanks a lot for the message.

IEEE-754 double precission floating point numbers are 64 bits. But
how can it use 64 bit number field to store 256 hex digits?


It doesn't. It only stores 53 significant bits, and then it uses some
more bits to tell how many zeroes comes after those.

That is why
Math.pow(2,52) != Math.pow(2,52)+1
but
Math.pow(2,53) == Math.pow(2,53)+1

It needs 54 bits to represent 2^53+1 precisely. Since there are only 53 bits
available, the least significant bit is lost.

(There are some extra details about how the bits are really used, but
I think they would only confuze matters here :)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
JRS: In article <4c**************************@posting.google.com >, seen
in news:comp.lang.javascript, chirs <ym*@kicon.com> posted at Sat, 4 Oct
2003 12:38:24 :-

What is the maximum number in JavaScript? I tried a large number like
0xff...ff with 30 fs, it still gives me a number, not an infinity. I
use IE6.


The maximum value of an object of type Number, etc., is about 1.7E308,
as the native number representation is as an IEEE Double.

But a programmer is free to construct entities using a different
notation, and to do arithmetic differently :

function BigFac(J) { var L = 0, k
for ( k=1 ; k<=J ; k++ ) L += Math.log(k)
L *= Math.LOG10E
return Math.exp((L%1)/Math.LOG10E) + 'E' + Math.floor(L) }

function TryBig() {
document.write('Thus<tt> 3333! = ', BigFac(3333), '<\/tt>') }

gives : Thus 3333! = 1.8497400355653586E10296

All integers up to and including 2^53 = 9007199254740992, and their
negatives, can be represented exactly.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #5

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

Similar topics

2
by: teddysnips | last post by:
SQL Server 2000 8.00.760 (SP3) I've been working on a test system and the following UDF worked fine. It runs in the "current" database, and references another database on the same server called...
2
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
2
by: mayur | last post by:
Hi, Can anyone help me with the following error I am getting in my asp.net application. The number name 'System.Web.UI.WebControls' contains more than the maximum number of prefixes. The maximum...
2
by: Michael.Suarez | last post by:
In MS Sql Server 2000, if you run a stored procedure that query's more than 8 databases, you get this error gets raised: Maximum number of databases used for each query has been exceeded. The...
29
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
3
by: Madmartigan | last post by:
Hello I have the following task but am battling with the final output. How do I keep two different vectors in sync and how would I retrieve the index for the maximum value of one of the vectors??...
2
by: Wayne | last post by:
Is there a "best practice" maximum number of controls that can be loaded on to a tab control before things start getting messy and sluggish? I'm asking for a "best practice" maximum number across...
6
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm using the VScrollBar and set it as follow: m_vScrollBar.Minimum = -19602; m_vScrollBar.Maximum = 0; m_vScrollBar.SmallChange = 1; m_vScrollBar.LargeChange = 1089; m_vScrollBar.Value =...
11
by: zj262144 | last post by:
Hi, I'm a C beginner. I want to write a C. The pseudocodes are like this: User enters some numbers (use -1 to end) The compiler find and delete the maximum and minimum numbers Then average...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.