Tell me more ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

What determines the value of $MaxNumber?

$MaxNumber
1.233433712981650*10^323228458

Mathematica can instantly calculate:

44787922`!
1.0809571*10^323228455

But refuses to calculate:

44787923`!

During evaluation of In[3]:= General::ovfl: Overflow occurred in computation. >>

Overflow[]

It seems like an arbitrary cutoff rather than a limitation of the system.

share|improve this question
The documentation example has 1.556812216564510*10^323228429 while my computer (32 bit) says 5.297557459040040*10^323228467. Yet another computer (64 bit) says that same value you quote. – Szabolcs Jan 22 '12 at 20:29

1 Answer

up vote 11 down vote accepted

If you calculate Log[2,Log[2,$MaxNumber]], you'll get 29.999999828017338886225739 which is remarkably close to 30. Therefore I conclude that Mathematica calculates with a 31-bit exponent (1 bit for the exponent's sign). Which means that if Mathematica uses the same ordering as IEEE floats (i.e. first sign bit, then exponent, then mantissa), the first 32 bits (i.e. exactly 4 bytes) of a Mathematica floating point number contain the sign and the exponent.

share|improve this answer
This sounds plausible. Is there any reason it needs to be the case, especially on a 64-bit system? I realize these are almost meaninglessly large numbers but Mathematica handles other fringe cases. – Mr.Wizard Jan 22 '12 at 20:37
Given that even on 64 bit systems, C-derived languages use 32-bit int, I can imagine that they once decided to implement the floating point format using int, and then didn't see the need to revise that decision because, after all, the numbers are large enough that you generally won't exceed them anyway. And every change has the potential to introduce new bugs. Of course that's just a guess; probably only Wolfram could give you a definitive answer. – celtschk Jan 22 '12 at 20:49
1  
I believe you are correct, except that in C an int can be any size greater than 16 bits. WRI probably chose 32 bits because that's the size of an int on all the platforms they currently support. Incidentally, in Mathematica 5.2, which was the first 64-bit version, the multiprecision implementation is not GMP as it is in current versions, and as a result $MaxNumber is larger (2.0931173222699136*^646456781). – Oleksandr R. Jan 31 '12 at 23:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.