Getting a slice of a float from an irrational number

139 views Asked by At

I am trying to find a way to slice an arbitrary index of an irrational number, eg. getting a slice of 5 digits of the Euler's number starting at the decimal index 100. This is not a practical task, just a thing I was wondering about.

I was trying to find an answer here

and sliced my number after converting my float into string:

z=str(format(math.e, '.105f'))[-6:-1]

It does work with floats with smaller precision (till around .50f), but with bigger it returns zeros. I was wondering how could I possibly represent and slice long floats.

1

There are 1 answers

0
Lior Cohen On

Python has a package bigfloat for this very high precision arithmetics.