Top "Floating-point" questions

Floating point numbers are approximations of real numbers that can represent larger ranges than integers but use the same amount of memory, at the cost of lower precision.

How can I convert a string to a number in Perl?

I have a string which holds a decimal value in it and I need to convert that string into a …

string perl floating-point
Make a float only show two decimal places

I have the value 25.00 in a float, but when I print it on screen it is 25.0000000. How can I display …

objective-c formatting floating-point
How do I convert Int/Decimal to float in C#?

How does one convert from an int or a decimal to a float in C#? I need to use a …

c# casting floating-point
Printf width specifier to maintain precision of floating-point value

Is there a printf width specifier which can be applied to a floating point specifier that would automatically format the …

c floating-point printf c99 floating-point-precision
What is the best way to compare floats for almost-equality in Python?

It's well known that comparing floats for equality is a little fiddly due to rounding and precision issues. For example: …

python floating-point
How to check if a float value is a whole number

I am trying to find the largest cube root that is a whole number, that is less than 12,000. processing = True …

python floating-point
Easy pretty printing of floats in python?

I have a list of floats. If I simply print it, it shows up like this: [9.0, 0.052999999999999999, 0.032575399999999997, 0.010892799999999999, 0.055702500000000002, 0.079330300000000006] I could use print "%.2…

python printing formatting floating-point
How to truncate float values?

I want to remove digits from a float to have a fixed number of digits after the dot, like: 1.923328437452 → 1.923 I …

python floating-point
C++ floating point to integer type conversions

What are the different techniques used to convert float type of data to integer in C++? #include <iostream> …

c++ floating-point integer type-conversion typecast-operator
Convert float to double without losing precision

I have a primitive float and I need as a primitive double. Simply casting the float to double gives me …

java floating-point double