0

It's possible to find the repeating part of a decimal by iterating through ever greater sections of the decimal and then checking it with the next chunk.

Ex.(1/28) 0.03571428571428571, 0.03[571428]571428

However, there are always rather large repetition lengths.

Ex. (31/89)

0.[34831460674157303370786516853932584269662921]34831460674157303370786516853932584269662921....

The problem with using javascript to evaluate a fraction out of 0.[34831460674157303370786516853932584269662921]34831460674157303370786516853932584269662921.... is that javascript has a max of 17 decimals. How do I get more decimals?

  • What @AmitJoki said. – The Blue Dog Oct 11 '14 at 17:19
  • the answer is you just cant .. – Avinash Babu Oct 11 '14 at 17:19
  • I think it's [IEEE](https://en.wikipedia.org/wiki/IEEE_floating_point)'s fault, and the size of 64 bits. Next gen might use 128 bits floats. – Rudie Oct 11 '14 at 17:20
  • 2
    You can use an [arbitrary-precision](http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic) math library to "longhand" calculate with more digits. See for example the answers [here](http://stackoverflow.com/questions/3072307/is-there-a-bignum-library-for-javascript). – mellamokb Oct 11 '14 at 17:22
  • So you'd have to use a separate math library... – Matthew Wang Oct 11 '14 at 17:33
  • Yes, @mellamokb is correct (you should turn this comment into an answer), and this applies to about any general-purpose programming language. Arbitrary precision arithmetic must be done in software, because the hardware isn't designed to support it out of the box (IEE 754). – Lucas Trzesniewski Oct 11 '14 at 17:47

1 Answers1

0

As mention in comments you can't. And tha't why:

Javascript is not a typed language so it should come as no surprise that there are no specific integer or floating-point types, no short, long, byte, double, or any other type other languages use to define numbers. All numbers in Javascript are 64bit (8 bytes) floating point numbers which yields an effective range of 5e-324 (negative) to 1.7976931348623157e+308 (positive).

This reference will cover Javascript numeric literals and objects as well as the default Javascript Operators which manipulate those numbers.

more..

Alex Char
  • 32,879
  • 9
  • 49
  • 70