I want to convert the number from decimal to hexadecimal number. The problems is the number is too big that cannot store in int datatype.For example,

int a = pow(10,17);

However, if I try to use double, I will face the problem of modulo operator because it does not support floating point datatype.

What should I do to convert it and store it? (Project Euler Problem Number 162).

有帮助吗?

解决方案

use can use long for that

To know the difference go Difference between long and int data types

You can convert int to long simply by

long variable=(long)a;

If that don't meet your requiremnet

You can use long long long long in C/C++

Conversion:

long long variable = (long long) a;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top