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


Common datatype in many programming languages for representing a whole number

Today units combinations

Quality Example
Division typically faster

"Floating-point division is typically faster than integer division on the cpu"

from question "Is MPFR division faster than native integer division?"


"Integer math is often much faster than floating-point so such a function could be a major performance win"

from question "Strange float rounding"

"Depending on context floating-point code may be as fast as or faster than integer code or it may be four times slower"

from question "Performance of C++ Operators"

"There are lots of cpu gpu combinations where a 32b integer multiply is faster than a 32b floating-point multiply on cpu and vice-versa on gpu"

from question "InstrA is faster than instrB on CPU but vice versa on GPU?"

"Today s floating-point units are pretty fast and may actually divide faster than an integer unit"

from question "How to integer-divide round negative numbers *down*?"

"Which uses all integer arithmetic is usually faster than its floating-point equivalent likely significantly faster in the case of a floating-point type equivalent to t-sql s decimal type"

from question "Is there a good reason for storing percentages that are less than 1 as numbers greater than 1?"

"It s even possible that you could implement pong using only integer arithmetic which is likely to be faster than floating-point -- but the difference is unlikely to be critical"

from question "Float_fast in C (similar to int_fast in stdint.h)"

"But another added benefit of this approach is that it could make your program run faster since fixed-point integer arithmetic is much faster than floating-point arithmetic"

from question "Is it possble to combine number of float values into one float value and extract the values when needed?"

Math slower

"They take up more space and floating-point math is slower than integer math"

from question "Performance implications of using BigDecimal vs. Integer in a Rails app"


"You re performing integer division which is coarser than floating-point division"

from question "Click in a shape WinForm"


"Floating-point may be somewhat slower than integer but it s generally"

from question "Why use the 'int' data type instead of the 'float' data type?"

"Historically floating-point could be much slower than integer arithmetic"

from question "Performance of built-in types : char vs short vs int vs. float vs. double"

"Historically floating-point could be much slower than integer"

from question "Why use the 'int' data type instead of the 'float' data type?"

"As a rule of thumb floating-point is about 2x slower than integer on"

from question "Float or Double?"

Math faster

"Generally integer math is faster than floating-point math"

from question "Performance of built-in types : char vs short vs int vs. float vs. double"

Divide faster

"Floating-point divide is faster than integer fewer bits to divide assuming your cpu has floating-point unit"

from question "How can i make this equation faster"

More complicated

"Floating-point arithmetics is by far more complicated than integer arithmetics"

from question "Float and int data types affects performance"


"But integer arithmetic arguably is inherently simpler than floating-point"

from question "How to simplify this code (generates a random int between min and max base on unsigned int)?"


Quality Example

"An individual floating-point division instruction will take longer than an integer one"

from question "Integer division vs double division - optimization question"


"I know c++ have functions that return largest or smallest integer that is greater or lower than a like ceil or there a function that implement digit limitation of floating-point variable"

from question "Digit limitation from decimal point in C++"


"Since the floating-point value is slightly less than the integer you rounded to thanks to .nextdown the integer part is going to be one less than that integer"

from question "Why, in Swift, when I convert from a Double to an Int is it subtracting 1?"

Higher rank

"Because the floating-point value is of a higher rank than an integer it will promote the integer to a float"

from question "What decides what datatype that will be used to store the temporary value in?"

Variables much more

"Floating-point representation in memory can t add third link - because floating-point variables is much more strange than integer ones"

from question "Write struct to file"

More general

"Floating-point solves the more general problem of representing some real numbers that aren t integers and some real numbers that are larger than the maximum integer up to which all integers are representable here 16777216 all with a nearly uniform relative accuracy at least 1 2 precision"

from question "What is it called when a floating point number is larger than its precision?"

Better results

"I did this very successfully with scipy.ndimage in the floating-point domain way better results than integer image processing like this"

from question "Counting particles using image processing in python"

Bigger numbers

"Nsdecimalnumber and the floating-point types may be able to store bigger numbers than the integer types though with decreasing precision"

from question "What's the largest value an NSNumber can store?"


"On somewhat limited processors like those in high-end cell phones floating-point may be somewhat slower than integer but it s generally within an order of magnitude or better so long as there is hardware floating-point available"

from question "Performance of built-in types : char vs short vs int vs. float vs. double"

Larger range

"Floating-point types have a larger range than the integer types so"

from question "Actual argument long cannot be converted to int by method invocation conversion"

Less exact

"However due to unpredictable floating-point precision issues it is sometimes little less than exact integer and in this case it is rounded down too much"

from question "D3D11/C++ Inaccuracies in uv interpolation in pixel shader. How to avoid?"

Back to Home
Data comes from Stack Exchange with CC-BY-SA-3.0