Comment on: Concerning type float, if I typed out 38 digits, put a decimal point anywhere on that number except for the ends, and chose my 7 significant digits, can I really deal with those significant digits?
0 30 Jan 2016 09:28 u/drinkingthehaterade in v/programmingComment on: Concerning type float, if I typed out 38 digits, put a decimal point anywhere on that number except for the ends, and chose my 7 significant digits, can I really deal with those significant digits?
The answer is yes. You can represent any number between 10^37 and 10^-39 to within 7 significant figures if using a 32 bit float. Using a 23 bit mantissa gives the smallest representable change in value of 1/(2^23)2^exponent for a given exponent. The largest value that a float can represent is approximately (2(2^exponent)) and divide that by the smallest representable change you get 2/(1/2^23) and take the log base 10 to find out how many decimal digits are significant which comes out to 7.2247 significant digits
See here for the significant figures for other data types. https://en.wikipedia.org/wiki/Floating_point#Internal_representation
I don't know what you are talking about. Every time you perform a calculation you get some unpresentable result and you have to round to the next closest float and since that float isn't the exact result you lose accuracy.
I don't know how in one sentence you can say it doesn't lose accuracy every time you do a calculation and then say that it can't represent every result in the very next statement. Unless you are doing operations where your operands are using the same exponent you're results are NEVER going to be some value that a float can represent and you will ALWAYS have some error.
Just take a look at Wikipedia if you need some examples on the horrible errors that you can get with floats. https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems