Integers (int type) are "whole numbers", without the fractional part, eg. 10. You use this type when the value is always an integer, e.g. a counter. Floating point numbers (float type) can have fractional part, e.g. 10.1234. They are stored using the closest representation in binary notation. Most numbers cannot be represented accurately, so they are slightly off. You use float for most mathematical calculations involving fractional numbers. Decimal numbers (Decimal type in Python) are used to represent floating point numbers accurately, with a defined precision (a defined number of places after decimal point). They are represented with two integer numbers, one for the integer part and one for the fractional part. For example. 10.1234 is stored as (10, 1234). Decimal type is required when fractional numbers must be represented accurately, with defined precision. The most notable example is financial calculations. Using float type you may get a result of a financial operation as 1010.123456$. But money is expressed with at most two decimal places. What does 0.123456$ mean? You can round it to 1010.12$, but then what happens with the remaining 0.003456$? Some "smart" programmers used that to their advantage in the past and they made a lot of money (which they eventually had to give back). So, for money calculations, you should use Decimal type. A good explanation of the Decimal type is in the documentation: https://docs.python.org/3/library/decimal.html Answer from gregvuki on reddit.com
Top answer
1 of 4
9
Integers (int type) are "whole numbers", without the fractional part, eg. 10. You use this type when the value is always an integer, e.g. a counter. Floating point numbers (float type) can have fractional part, e.g. 10.1234. They are stored using the closest representation in binary notation. Most numbers cannot be represented accurately, so they are slightly off. You use float for most mathematical calculations involving fractional numbers. Decimal numbers (Decimal type in Python) are used to represent floating point numbers accurately, with a defined precision (a defined number of places after decimal point). They are represented with two integer numbers, one for the integer part and one for the fractional part. For example. 10.1234 is stored as (10, 1234). Decimal type is required when fractional numbers must be represented accurately, with defined precision. The most notable example is financial calculations. Using float type you may get a result of a financial operation as 1010.123456$. But money is expressed with at most two decimal places. What does 0.123456$ mean? You can round it to 1010.12$, but then what happens with the remaining 0.003456$? Some "smart" programmers used that to their advantage in the past and they made a lot of money (which they eventually had to give back). So, for money calculations, you should use Decimal type. A good explanation of the Decimal type is in the documentation: https://docs.python.org/3/library/decimal.html
2 of 4
7
Python's integers (±0, 1, 2, etc.) have unlimited accuracy, which is unusual as far as programming languages go. In most languages they usually cap at 64-bits (aka long int) and there may be multiple integer types of various sizes. This makes Python very useful for scientific computing as you don't need a separate BigNum library to handle arbitrary precision. Python's floating-point numbers don't quite have this same luxury due to the inaccurate nature of them. Since many decimal numbers cannot be accurately represented in binary, floating-point math will always run into inaccuracies. For instance, 0.1 + 0.1 + 0.1 isn't 0.3, but something like 0.3000000000001. You'll use floats whenever whole numbers aren't enough, but you don't need a specific amount of accuracy. You probably never meant to ask about this, but decimal.Decimal is an alternative to float that lets you set its precision yourself. It's still not infinitely accurate, but it's often used in scientific computing where integers just can't cut it.
🌐
Processing
processing.org › examples › integersfloats.html
Integers Floats / Examples / Processing.org
Integers and floats are two different kinds of numerical data. An integer (more commonly called an int) is a number without a decimal point. A float is a floating-point number, which means it is a number that has a decimal place.
Discussions

floating point - Difference between decimal, float and double in .NET? - Stack Overflow
Again, the number and the location of the decimal point are both encoded within the value – that's what makes decimal still a floating point type instead of a fixed point type. The important thing to note is that humans are used to representing non-integers in a decimal form, and expect exact ... More on stackoverflow.com
🌐 stackoverflow.com
Why do we need to differentiate between float numbers and integers?
There are many reasons: It is faster for the computer to do math with integers than with floats. Floats accumulate errors, so if you don't need them, integers are more robust. For example 0.1+0.2 != 0.3. There are situations in which floats don't make sense but integers do. For example when accessing an item in a list, my_list[3] makes sense but my_list[3.57] does not. Every programming language (except JavaScript) also separates them. Many also have more than 1 type of int and float (for different sizes). More on reddit.com
🌐 r/learnpython
9
5
August 13, 2022
Integer vs Float
I need to explain to people the difference between integers and floats as they relate to displaying decimal places in an HMI application. Is there a document that explains this in laymen terms. I am trying to get across that an integer cannot display a floating point value but that two... More on plctalk.net
🌐 plctalk.net
1
January 14, 2008
What is the difference between int and double and how do you know when to use them?
Well they can't really be interchanged. An int is used to represent integer numbers (+- whole numbers). While a double is used to represent a double precision floating point number. The actual size of each is system dependent but a double will be two times the size of a float. I'd recommend reading up on this with an intro to C tutorial or even just something on basic datatypes. More on reddit.com
🌐 r/C_Programming
16
0
February 6, 2015
Top answer
1 of 3
118
  • float stores floating-point values, that is, values that have potential decimal places
  • int only stores integral values, that is, whole numbers

So while both are 32 bits wide, their use (and representation) is quite different. You cannot store 3.141 in an integer, but you can in a float.

Dissecting them both a little further:

In an integer, all bits except the leftmost one are used to store the number value. This is (in Java and many computers too) done in the so-called two's complement, which support negatives values. Two's complement uses the leftmost bit to store the positive (0) or negative sign (1). This basically means that you can represent the values of −231 to 231 − 1.

In a float, those 32 bits are divided between three distinct parts: The sign bit, the exponent and the mantissa. They are laid out as follows:

S EEEEEEEE MMMMMMMMMMMMMMMMMMMMMMM

There is a single bit that determines whether the number is negative or non-negative (zero is neither positive nor negative, but has the sign bit set to zero). Then there are eight bits of an exponent and 23 bits of mantissa. To get a useful number from that, (roughly) the following calculation is performed:

M × 2E

(There is more to it, but this should suffice for the purpose of this discussion)

The mantissa is in essence not much more than a 24-bit integer number. This gets multiplied by 2 to the power of the exponent part, which, roughly, is a number between −128 and 127.

Therefore you can accurately represent all numbers that would fit in a 24-bit integer but the numeric range is also much greater as larger exponents allow for larger values. For example, the maximum value for a float is around 3.4 × 1038 whereas int only allows values up to 2.1 × 109.

But that also means, since 32 bits only have 4.2 × 109 different states (which are all used to represent the values int can store), that at the larger end of float's numeric range the numbers are spaced wider apart (since there cannot be more unique float numbers than there are unique int numbers). You cannot represent some numbers exactly, then. For example, the number 2 × 1012 has a representation in float of 1,999,999,991,808. That might be close to 2,000,000,000,000 but it's not exact. Likewise, adding 1 to that number does not change it because 1 is too small to make a difference in the larger scales float is using there.

Similarly, you can also represent very small numbers (between 0 and 1) in a float but regardless of whether the numbers are very large or very small, float only has a precision of around 6 or 7 decimal digits. If you have large numbers those digits are at the start of the number (e.g. 4.51534 × 1035, which is nothing more than 451534 follows by 30 zeroes – and float cannot tell anything useful about whether those 30 digits are actually zeroes or something else), for very small numbers (e.g. 3.14159 × 10−27) they are at the far end of the number, way beyond the starting digits of 0.0000...

2 of 3
3

Floats are used to store a wider range of number than can be fit in an integer. These include decimal numbers and scientific notation style numbers that can be bigger values than can fit in 32 bits. Here's the deep dive into them: http://en.wikipedia.org/wiki/Floating_point

🌐
Codenga
codenga.com › pages › guides › float_vs_integer
What Is The Difference Between Float and Integer? - Codenga
If you are dealing with whole numbers or require exact precision, use integers. If the data involves decimal parts or decimal calculations, use floats.
🌐
IBM
ibm.com › docs › en › idr › 11.4.0
InfoSphere Data Replication
Binary integer includes small integer and large integer. Floating-point includes single precision and double precision. Binary numbers are exact representations of integers; decimal numbers are exact representations of real numbers; and floating-point numbers are approximations of real numbers.
🌐
GeeksforGeeks
geeksforgeeks.org › python › difference-between-integer-and-float-in-python
Difference Between Integer and Float in Python - GeeksforGeeks
July 23, 2025 - Positive Integer: 42 Negative Integer: -17 Large Integer: 9876543210123456789012345678901234567890 Sum Result: 25 Product Result: 414814814825185185138518518513851851851380 · In Python, a float is a numeric data type representing decimal numbers.
Top answer
1 of 16
2627

float (the C# alias for System.Single) and double (the C# alias for System.Double) are floating binary point types. float is 32-bit; double is 64-bit. In other words, they represent a number like this:

10001.10010110011

The binary number and the location of the binary point are both encoded within the value.

decimal (the C# alias for System.Decimal) is a floating decimal point type. In other words, they represent a number like this:

12345.65789

Again, the number and the location of the decimal point are both encoded within the value – that's what makes decimal still a floating point type instead of a fixed point type.

The important thing to note is that humans are used to representing non-integers in a decimal form, and expect exact results in decimal representations; not all decimal numbers are exactly representable in binary floating point – 0.1, for example – so if you use a binary floating point value you'll actually get an approximation to 0.1. You'll still get approximations when using a floating decimal point as well – the result of dividing 1 by 3 can't be exactly represented, for example.

As for what to use when:

  • For values which are "naturally exact decimals" it's good to use decimal. This is usually suitable for any concepts invented by humans: financial values are the most obvious example, but there are others too. Consider the score given to divers or ice skaters, for example.

  • For values which are more artefacts of nature which can't really be measured exactly anyway, float/double are more appropriate. For example, scientific data would usually be represented in this form. Here, the original values won't be "decimally accurate" to start with, so it's not important for the expected results to maintain the "decimal accuracy". Floating binary point types are much faster to work with than decimals.

2 of 16
1303

Precision is the main difference.

Float - 7 digits (32 bit)

Double-15-16 digits (64 bit)

Decimal -28-29 significant digits (128 bit)

Decimals have much higher precision and are usually used within financial applications that require a high degree of accuracy. Decimals are much slower (up to 20X times in some tests) than a double/float.

Decimals and Floats/Doubles cannot be compared without a cast whereas Floats and Doubles can. Decimals also allow the encoding or trailing zeros.

float flt = 1F/3;
double dbl = 1D/3;
decimal dcm = 1M/3;
Console.WriteLine("float: {0} double: {1} decimal: {2}", flt, dbl, dcm);

Result :

float: 0.3333333  
double: 0.333333333333333  
decimal: 0.3333333333333333333333333333
Find elsewhere
🌐
Reddit
reddit.com › r/learnpython › why do we need to differentiate between float numbers and integers?
r/learnpython on Reddit: Why do we need to differentiate between float numbers and integers?
August 13, 2022 -

Hi all. Im a complete beginner learning the basics. Im curious as to why Python has two different types of numbers (3 including complex) : Floats and integers. Why cant we just use any number and if we do wanna use a decimal point, we just use a decimal point without having to indicate it as a float? What is the significance of differentiating the two? Thanks!

Top answer
1 of 7
9
There are many reasons: It is faster for the computer to do math with integers than with floats. Floats accumulate errors, so if you don't need them, integers are more robust. For example 0.1+0.2 != 0.3. There are situations in which floats don't make sense but integers do. For example when accessing an item in a list, my_list[3] makes sense but my_list[3.57] does not. Every programming language (except JavaScript) also separates them. Many also have more than 1 type of int and float (for different sizes).
2 of 7
4
we just use a decimal point without having to indicate it as a float We can? print(type(1.5)) # There are at least 2 very good reasons to have separate types, though. The first is logical. Floating point math is inexact. For example: >>> (1 - 0.1) - 0.9 0.0 >>> (1 - 0.05 - 0.05) - 0.9 -1.1102230246251565e-16 As you can see, the more calculations with make with floating point arithmetic, the more likely it is we'll accumulate inaccuracies. This does not happen with integers, and we would certainly like to have the option of avoiding this problem whenever possible. It's not possible to eliminate this problem in rational numbers without giving a fractional number unlimited storage space, which is obviously undesirable in a variety of use cases. The second is practical. The algorithms for integer arithmetic are dramatically different. Integer arithmetic uses 2's complement, and floating point arithmetic uses the IEEE 754 standard for representing decimal numbers and performing computations on them. These different representations are what allows us to preserve precision in integers. Also, integer arithmetic is much faster than floating point arithmetic. When only integer arithmetic is needed over a large amount of data, computation will be significantly faster.
🌐
PLCS.net
plctalk.net › home › forums › q & a › plc questions and answers
Integer vs Float | PLCtalk - Interactive Q & A
January 14, 2008 - Floating point uses the bits in a different way from an integer. They normally use 32 bits (the same as the double integer) to convey a value. The value can be 'tenths' or 'hundreths' or 'billions' or 'trillions' etc.
🌐
Secoda
secoda.co › learn › in-depth-guide-to-sql-data-types-differences-and-best-practices
In-Depth Guide to SQL Data Types: Differences and Best Practices | Secoda
August 12, 2024 - The main difference between INTEGER and FLOAT data types in SQL is that INTEGERs store whole numbers, while FLOATs store approximate numerical values with decimal places.
🌐
Coderanch
coderanch.com › t › 593278 › java › difference-decimal-float-decimal-integer
difference between decimal,float and decimal integer (Beginning Java forum at Coderanch)
September 23, 2012 - That means you write it using the digits 0-9. The Integers are the set of numbers that include the Natural numbers, their negatives, and 0. You can write an Integer in decimal, in octal, in hexidecimal, in binary...but no matter how you write it, the value is the same.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › visual-basic › programming-guide › language-features › data-types › numeric-data-types
Numeric Data Types - Visual Basic | Microsoft Learn
September 15, 2021 - Floating-point (Single and Double) numbers have larger ranges than Decimal numbers but can be subject to rounding errors.
🌐
Arm Learning
learn.arm.com › learning-paths › cross-platform › integer-vs-floats › introduction-integer-float-types
Learn about integer and floating-point conversions: An introduction to integer and floating-point data types
First, notice that the initial value of x is not 0.9999998 that was originally assigned. It is now the closest float 0.99999982118607 with a hex value of 0x3f7ffffd. Second, even though the program prints 14 decimal digits, the resolution of the float datatype is definitely not 14 digits.
🌐
Oracle
docs.oracle.com › en › cloud › saas › enterprise-data-management-cloud › dmcaa › expressions_datatype_integer_and_float.html
Integer and Float
1 week ago - An integer is a whole number and a floating-point value, or float, is a number that has a decimal place.
🌐
javathinking
javathinking.com › blog › what-is-the-difference-between-the-float-and-integer-data-type-when-the-size-is-the-same
Float vs Integer Data Type: What's the Difference When Size is the Same? — javathinking.com
Integers prioritize exactness—every value within their range is represented precisely. Floating-point numbers (or "floats") store numbers with decimal points or values too large/small for integers (e.g., 3.14159, 2.998e8 for the speed of light).
🌐
Sololearn
sololearn.com › en › Discuss › 3057798 › difference-between-float-and-int
Difference between float and int
July 9, 2022 - Sololearn is the world's largest community of people learning to code. With over 25 programming courses, choose from thousands of topics to learn how to code, brush up your programming knowledge, upskill your technical ability, or stay informed about the latest trends.
🌐
Differences Between
difbetween.com › differences between › integer vs float
Integer vs Float
July 10, 2025 - The distinction between Integer and Float stems primarily from the underlying primitive data types they represent: Integer corresponds to the ‘int’ primitive, designed for whole numbers, while Float corresponds to the ‘float’ primitive, intended for representing single-precision floating-point numbers.
🌐
Mount Allison University
mta.ca › ~rrosebru › oldcourse › comp1711 › 171102 › comp1711A › numbers.html
Primitive Data Types
A primitive data type is only a value. It has no methods. This is because primitive data types are provided as part of the java language - not through a java class definition · The java language provides many different primitive data types to represent and store numeric values.
🌐
Sololearn
sololearn.com › en › Discuss › 1659792 › what-is-the-difference-between-int-double-and-float
What is the difference between int double and float? | Sololearn: Learn to code for FREE!
December 10, 2023 - A number which doesn't have decimal point like 3,45,19737,1639330 etc is called integer. A number which has decimal point or you can say fractional values is called float.e.g 2.3,4.578,235.368437 etc.