C++ static_cast<int>(double) screws up for some reason..?

0

I am writing a program that converts a hexadecimal number to a decimal number (without using the std::hex and std::dec stuff), and at one point need to change from a double to an int.. However when large numbers, such as 5,726,623,060.00000 are entered, they all get changed to -2,147,483,648 after being run through static_cast<int>... Any help as to how to get them to be converted correctly to (i.e 5,726,623,060.00000 to 5,726,623,060) would be very much appreciated!! Thanks!! :)

That number exceeds the largest value of the signed (and even unsigned) 32-bit integer. If you need numbers that large, your instructor may be seeking a solution where you represent your numbers by an array or ints or chars.

Oh, does it also exceed the largest value of a long integer? If so, is there another method in which I can do integer division without the number actually being an integer?? Right now I have the following in a loop with some other code to convert the hex number to a decimal number, and it works for any hex number with less than 8 digits, but if I get more than that it fails. I suppose that must be due to it exceeding the max value of an int, so is there a way for me to do the division in the following code as integer division without the number 'divider' actually being an integer?? Thanks! Code:

Summing each new calculation into your array (you don't need more than one, just make sure you have things lined up and do the carries properly. This way you increase your capacity dramatically.

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...

Hi. so this is actually a continuation from another question of mineHere but i was advised to start a new thread as the original question was already answered.

This is the result of previous question answered :

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...