Answer the question
In order to leave comments, you need to log in
What is the problem in data types when looking for factorial?
* There was a task in the laboratory, to calculate the factorial.
If you specify the int type as requested, then the factorial is considered incorrect after the value 8.
If long, then after 12, I looked at the calculator. The only way out is long double.
What is the question, why do errors occur with data types, I read something related to the bit depth of the percent, but I didn’t understand anything. And how to solve the problem, so that you can display just a number like in a calculator, and not a floating point number.
Answer the question
In order to leave comments, you need to log in
For each data type, there is a maximum (and minimum) number that can be set to a variable of that type. The factorial grows so fast that very soon the bitness of standard data types is no longer enough.
There are data types with arbitrary bit depth. Search for the phrase "long arithmetic".
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question