简体   繁体   中英

error in result while doing large mathematical operations in C

I have used long long result; to store the result of 150 to power 53 but still it is giving -8 result in C. I dont know what to use to store such large values in C.

An integer representation of 150 to the power 53 would require exactly 384 bits. The width of long long -- if it's even supported -- could vary, but 128 bits is common, and I would be surprised to see it longer than 256 bits.

You can represent the value using some variety of bignum library (in which case you would also need to use that library to manipulate it). Alternatively, you could store it as a double . A double can represent numbers of that magnitude, but they have limited precision. For many purposes they are entirely sufficient.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM