finally, hahaha, yea i guess that was the prob, i wasn't allocating enough memory for the variables so it was spitting back weird numbers
thanks for all the help guys
finally, hahaha, yea i guess that was the prob, i wasn't allocating enough memory for the variables so it was spitting back weird numbers
thanks for all the help guys
Note that matsp's explanation of how floating point types are represented are not guaranteed by the standard, those are just common implementations on current architectures.
The standard basically just says that double is at least as precise as float, and long double is at least as precise as double.
if basically each are only as precise as the other, why have three different types in the first place?
at least as precise
The wording of the standard says so because there are some machines that only have ONE type of floating point number, and other machines with two, or three or four different floating point formats. For the standard to work on ALL of those, it gives some flexibility to the implementor of the compiler to choose different forms that are good for the architecture you are implementing on. For example, some machine may only have a "double" type floating point number. So even if you choose "float", you get the same thing as "double". On another machine, there are "single" and "double" precision floating point. On a third machine there's single, double and extended floating point. What the standard guarantees is that the precision of a double is at least as good as float - so if you choose double, you get a "good precision", whilst "float" may not be as precise.
It's actually the same for integers. The only guarantee about "long" for example, is that it's not SHORTER than an "int" - and that "short" isn't longer than "int". But there's nothing saying that they all can't be the same size on a machine where that's "the best solution".
--
Mats
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.