문제

I am dealing with a math example. I need to use 12 digit number for my code. So which datatype should i use, to use the number in my functions?

도움이 되었습니까?

해결책

64-bit integers (long, int64_t, unsigned long, uint64_t) should do the trick, or if you need decimals, double or long double.

다른 팁

If you have a 64-bit integer type, I'd go with that, since it gives you the (18 full digits) range:

−9,223,372,036,854,775,808 to
+9,223,372,036,854,775,807

For other tasks (even bigger integers or massive floating point values), I use GMP, the GNU multi-precision library. It's performance is impressive.

you can also use "unsigned long long" with format specifier "llu". It works fine for 12 digit number in C.

unsigned long long i=600851475143;
printf("%llu",i);

While looking for a library called Bignum I've found this wiki page

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top