本文介绍了作为字符串存储的大量100位数的除法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个100位数字存储为字符串。我想将该数字除以小于10的整数。如何有效地将存储为字符串的大整数除以整数?

I have a 100 digit number stored as string. I want to divide this number with an integer less than 10. How do I efficiently divide a big integer stored as a string with an integer?

推荐答案

您可以检查。

您可以在C ++程序中使用此库可对仅受计算机内存限制的整数进行算术运算。该库提供BigUnsigned和BigInteger类,分别表示非负整数和有符号整数。对于这些类,大多数C ++算术运算符都已重载,因此大整数计算非常简单:

You can use this library in a C++ program to do arithmetic on integers of size limited only by your computer's memory. The library provides BigUnsigned and BigInteger classes that represent nonnegative integers and signed integers, respectively. Most of the C++ arithmetic operators are overloaded for these classes, so big-integer calculations are as easy as:

#include "BigIntegerLibrary.hh"

BigInteger a = 65536;
cout << (a * a * a * a * a * a * a * a);

(prints 340282366920938463463374607431768211456)

也请检查

这篇关于作为字符串存储的大量100位数的除法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 20:02