983 / Num

Single file header only C++ implementation of BigInteger / BigNum / unlimited size integers and rational numbers
The Unlicense
67 stars 16 forks source link

How to convert Num to int #3

Open karlphillip opened 6 years ago

karlphillip commented 6 years ago

I understand Numcan store really big integers. However, sometimes it can store a small number. In this scenario, what would be the best way to convert Num to a regular int?

983 commented 1 year ago

The function bool can_convert_to_int(int *result) converts a Num to int, but only if it would fit.

I also thought about overloading cast to int, but it seemed too unsafe. I wanted to discourage conversion where it is not possible.

Documentation could certainly be improved.