Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Why does the factorial of an integer become negative? For example, write a program, input n and output n factorial, when n >; 20 output negative numbers?
Why does the factorial of an integer become negative? For example, write a program, input n and output n factorial, when n >; 20 output negative numbers?
The integer storage space is 2 bytes, 16 binary bits. The range of values is -215th power to 215th power (32767), and the factorial of 20 is equal to 2.43 *18th power, which is about equal to 218th power, exceeding the upper limit. At this time, you can use a long integer byte of 4 bytes and add L after the integer, and the range can be expanded to the plus or minus 2 power of 3 1. As for floating-point type, I still don't understand it, and I soon learned it. I am also making up C language. If you have any questions, watch the C language tutorial and learn the video tutorial while using it. If necessary, I will send it to the silly pig. It must be more serious than a satisfactory answer. Pure manual input, no copy and paste, so the power format is not expressed. Please forgive me! ?

Silly pig, the number of my helpers is quite high, and the list has been permanently banned. . .