I'm working on Project Euler's problem 26, which involves finding repetitions in the decimal place when I do division such as 1/6, 1/7, 1/8 etc.
I'm having a hard time getting BigDecimal
to give enough precision to find long patterns of repetition. I'd like to force precision of an arbitrary number of places; however, using round(x)
still caps at around 18 places.
puts (BigDecimal("1.0") / 7).round(25).to_s("F")
puts (BigDecimal("1.0") / 7).round(25).precs
yields 0.142857142857142857
and [18, 27]
, respectively. What is the reason it is limited to 18 decimal places? Is there a way to get meaningful decimals past that, or even past the system limit of 27?