mirror of
https://hub.njuu.cf/TheAlgorithms/C-Plus-Plus.git
synced 2023-10-11 13:05:55 +08:00
use cinttypes for size specific int type
This commit is contained in:
parent
ca08e3e9a2
commit
6276e4ec06
@ -6,6 +6,7 @@
|
|||||||
#ifndef OTHERS_LARGE_NUMBER_H_
|
#ifndef OTHERS_LARGE_NUMBER_H_
|
||||||
#define OTHERS_LARGE_NUMBER_H_
|
#define OTHERS_LARGE_NUMBER_H_
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cinttypes>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -21,9 +22,9 @@ class large_number {
|
|||||||
public:
|
public:
|
||||||
large_number() /**< initializer with value = 1 */ { _digits.push_back(1); }
|
large_number() /**< initializer with value = 1 */ { _digits.push_back(1); }
|
||||||
|
|
||||||
large_number(unsigned long n) /**< initializer from an integer */
|
large_number(uint64_t n) /**< initializer from an integer */
|
||||||
{
|
{
|
||||||
unsigned long carry = n;
|
uint64_t carry = n;
|
||||||
do {
|
do {
|
||||||
add_digit(carry % 10);
|
add_digit(carry % 10);
|
||||||
carry /= 10;
|
carry /= 10;
|
||||||
|
Loading…
Reference in New Issue
Block a user