Could i ever equal 2? Does the computer store d like 3.000.....321 and 2.999....99732? Or only ever the first? I don't really know anything about how floating point numbers are stored.
I have a number which I know is an integer but is stored in the file in float format, i.e. 3.0000. So when I read it I'm using fscanf(file,"%lf",*double). However I want to use it for loops and other stuff - like array indexes and map keys. So can I just assign the double to an int - as shown in the code above - is this safe?
It can be "dangerous" as the value in the double could either be higher than what an int can handle, or have decimal values that will be lost when stored in an int. Depending on the use, this may or may not be an issue.
lols, reminds me of the "whole" part and the "mantissa" from assembly class and the IEEE standard of how a double is represented in memory.... anyway if you are not worried about data loss, then truncate that shiz...:
var = static_cast <data type> (var to cast);
if you are worried about about a particular memory location, then use a pointer and memory arithmetic:
var = pointer* (base addy of var, if you know the size of the addy type then do pointer math) and dereference when needed :)