Question

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).

Était-ce utile?

La solution

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;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top