I am well aware that the float data type's maximum value is approximately 1.8E308, which means that across the various programming languages such as dearly beloved Java, the maximum factorial we can compute with this primitive data type is that of 170. Trying to compute the factorial of 171 and beyond gives errors. Here, PHP behaves the same way. In one of the answers from here, JavaScript also poses problems with factorials greater than 170. I understand that all this happens because that is what the de facto standard defines. My question is, are there non-esoteric programming languages that don't adhere to the IEEE 754-2008 standard? If there are, it would be interesting to see how they deal with factorials.

  • $\begingroup$ At a guess, you would have to program extended representations of floats or doubles—this happens commonly with integral types (python’s arbitrary-precision integers), but I dont know if its done with floats. I think Eric Lippert has some blog posts about floating point representation. $\endgroup$ – D. Ben Knoble Nov 17 '19 at 17:05
  • $\begingroup$ I would assume any language designed before 2008? $\endgroup$ – Jörg W Mittag Nov 26 '19 at 4:08
  • $\begingroup$ @D.BenKnoble, "...program extended representations of floats or doubles." That sounds dangerous! $\endgroup$ – Stephen Muga Nov 26 '19 at 9:16
  • $\begingroup$ @JörgWMittag, that's also true. I've stumbled upon posts about Elm and Rust claiming non-adherence. The marked answer carries more weight though, because C and C++ are older languages but they may adhere to it. Here, we learn, ...should return true if IEEE 754 is in use, false otherwise.. Why the 50-50 chances? Shouldn't it totally stick to it? $\endgroup$ – Stephen Muga Nov 26 '19 at 9:27

For example, C and C++ don’t adhere to it. They don’t define the details of floating point arithmetic. An implementation may adhere to that standard, and there is a standard way to inform the user about it.

I used one compiler with ieee compliant 32 and 64 bit floating point, and totally non-compliant 128 bit fp with roughly 105 bit mantissa.

  • $\begingroup$ Huh. Interesting. $\endgroup$ – Stephen Muga Nov 18 '19 at 10:59
  • 1
    $\begingroup$ long double = pair of two double precision numbers x, y with the property that round (x + y) = x. Very interesting. $\endgroup$ – gnasher729 Nov 18 '19 at 12:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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