I have a program I am working on that will tell you the approximate time of a download based on the size of the file and the speed of your internet. This is just practice to help me retain the things I am learning in my college C++ course. The problem I am having is that 1 gb is over 8 billion bits and that number is too large for the standard int. So I used unsigned long long, but first once the number becomes small again I do not know how to convert it back to an int. It keeps saying possible loss of data. Also the numbers come up as a negative instead of a positive. Can someone help me fix this?
1. Convert the speed in bits per second to bytes per second by dividing it by eight.
2. Divide size in bytes by speed to get time in seconds.
Store everything in doubles.
That would work, but I would still like to know why the numbers returned are negative? Because there may be a day where I cant adjust the math and will have a large number to work with.