Answer the question
In order to leave comments, you need to log in
How to implement multiplication of numeric values in C++?
Guys, I'm completely noob in C ++, but I really want to master this language, just for myself.
In essence:
Everyone knows the history of the chessboard, more precisely with the progression of 2 to the 64th power. And so I actually decided to write a program that will display values from 1 to (well, a large number is obtained there). In general, I write in 1C, and the code listing for such a task will look like this:
А = 1;
Ит = 1;
Сум = 0;
Пока Ит <= 63 Цикл
Сообщить(Строка(Ит)+"---"+Строка(А));
Сум = Сум + А;
А = А*2;
Ит = Ит+1;
КонецЦикла;
Сообщить(Строка(Ит)+"---"+Строка(А));
Сум = Сум + А;
Сообщить("Результат количество: " + Строка(Сум),СтатусСообщения.Важное);
Сообщить("Результат вес в кг: " + Строка(Окр(Сум*0.00004,2,РежимОкругления.Окр15как20)),СтатусСообщения.Важное);
Сообщить("Результат вес в т: " + Строка(Окр(Сум*0.00004/1000,2,РежимОкругления.Окр15как20)),СтатусСообщения.Важное);
Answer the question
In order to leave comments, you need to log in
No standard type in crosses can accommodate a number larger than 2^64-1, so your program won't work.
You will have to deal with long arithmetic, that is, with a
GMP -
type library .
Use another type whose dimension will allow you to display the desired number. All sorts of unsigned long and so on.
if they are not enough - google about the mathematics of large numbers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question