float overflow
-
Hi, i have a variable of type float that get a return value thats greater than what float or double, long double etc can hold. The return data does not need to be so precise, example it holds 1.1520230e-007 when it overflows, and i really just need 1.1520230. However when the variable overflows like this i cant print it, i cant cast it or move it to a buffer. Is there a c\c++ function that truncates it, i have tried to cast the return data as type float but no success. Also i cant pass it to a buffer to then shorten it later as VS ignores the data except in the debug-watch window. Any ideas are much appreciated. Regards, Fred
-
Hi, i have a variable of type float that get a return value thats greater than what float or double, long double etc can hold. The return data does not need to be so precise, example it holds 1.1520230e-007 when it overflows, and i really just need 1.1520230. However when the variable overflows like this i cant print it, i cant cast it or move it to a buffer. Is there a c\c++ function that truncates it, i have tried to cast the return data as type float but no success. Also i cant pass it to a buffer to then shorten it later as VS ignores the data except in the debug-watch window. Any ideas are much appreciated. Regards, Fred
Hi Fredrick, sorry, but this does not make much sense. Overflow is when a number becomes so large the data type can no longer represent it; it would happen e.g. when you start with one, and keep multiplying by 10. 1.1520230e-007 is not the same as 1.1520230; it is actually 10 million times smaller. also a number such as 1.1520230e-007 is far away from overflowing either the float or double type. I suggest you rethink your problem, and/or reformulate what it is you want. :)
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.