mruby / mruby

Lightweight Ruby
MIT License
5.3k stars 787 forks source link

MRB_INT64 effective digit #827

Open masuidrive opened 11 years ago

masuidrive commented 11 years ago

When I defined MRB_INT64, Fixnum effective digit has problem. The reason, double's effective digit is less than int64's.

If mrb_int is 64bits, double should be long double. but some arch doesn't have long double, (ex iOS)

ex)

4611686018427387904 / 1 => 4.6116860184274e+18

matz commented 11 years ago

I am not sure what's your point.

Arithmetics that falls into float might lose precision as natural result. What behavior do you want to have, considering long double is not portable?

monaka commented 11 years ago

long double is C99 compliant. So we can use it. And its size is implementation dependent.

I'm not definite since I've not touch iOS inside yet. Maybe sizeof(double) == sizeof(long double) in iOS world. @masuidrive, is this bingo?

masuidrive commented 11 years ago

@monaka Bingo! double and long double is same size on iOS.

monaka commented 11 years ago

Hmm... It's not a limitation of iOS but FPU inside hardware (if my knowledge is correct). We will face similar issues as some FPU only have 64bit registers. Generally, we will use 32bit integer on such systems since they will have poor CPU power.

It seems like iOS devices are few exceptions.

monaka commented 11 years ago

BTW, I think it's good idea to add long double support. We can't follow iOS by this improvement. But it gives server side developers happy as they have FPU more than 64bit.