Double is the default decimal point type for Java. float is a 32 bit IEEE 754 single precision Floating Point Number1 bit for the sign, (8 bits for the exponent, and 23* for the value), i.e. To avoid the typecasting every time we write the number in float, we can suffix the number with ‘f’. Le double fait 8 octets de long. Float - … For this blog, we have focussed on how programming languages use these floating-point numbers to get precision values and range. Both float and double data types were designed especially for scientific calculations, where approximation errors are acceptable. It is also a good idea to know how particular data is stored in the database. But, if you deal with a lot of numbers where high precision is involved and any rounding off can change results – like trigonometry, width of a human hair, neural networks, spin of an electron, coordinates of a location and so on – it is important to know about the differences between float and double. It is thus easier and more accurate to use floating-point representation for high-precision calculations (as we will see in the next section). While Java encourages you to use double, in languages like C you have the flexibility of using whichever you want. Floats and doubles are used to store numbers with numbers after the decimal point. double d; I know best practices are fraught with contradictions, so I know the answers may vary here. The double data type is generally used for decimal values just like float. The value in float can range from 1.4e-045 to 3.4e+038 whereas, the value of type double can range from 4.9e-324 to 1.8e+308. The Floating-point numbers are the real numbers that have a fractional component in it. We use DECIMAL data type to store exact numeric values, where we do not want precision but exact and accurate values. If you want to read about floating-point numbers from an arithmetic point of view, you can read this Wikipedia article. For example, to store the annual salary of the CEO of a company, double will be a more accurate choice. : It is double precision. We use the operators <, <=, >= and > to compare float and double values. That can be kind of confusing because one is called float, but they are actually both called floating point. .net - sharp - difference between float and double with example . Difference between Decimal, Float and Double The main difference is Floats and Doubles are binary floating point types and a Decimal will store the value as a floating decimal point type. Another similar precision type is the symbolic computation where we use exact values of symbols (like PI) for complex computations. You can consider it as a trade-off between accuracy and memory efficiency. In Swift Programing language official documentation, It says Double represents a 64-bit floating-point number. This not only minimizes the amount of storage required but also improves performance. On Intel Haswell the difference between float and double is small, but on ARM Cortex-A9 the difference is big. Float used for single precision 2. If high precision is not required and the program only needs a huge array of decimal numbers to be stored, float is a cost-effective way of storing data and saves memory. This is the complete difference between Double vs Float; While typecasting from float to double and double to float is perfectly allowed and valid, it should be done carefully in the code. One of the most important applications of arbitrary precision is public-key cryptography where computations with numbers having hundreds of digits (exponential) are a common sight. Learn: Difference between float and double in java?Here, we will learn about float and double data types in java?Compare float and double in java. As you might know, float and double both can be used to represent floating point number in java. To be more precise, here's the official size: float: 1.5 × 10^-45 to 3.4 × 10^38 double: 5.0 × 10^-324 to 1.7 × … The pie that we choose to divide the numbers makes a difference in the significant digits of the result. For example. However, double comes with a cost. To sum up: * [code ]float[/code] is represented in 32 bits, with 1 sign bit, 8 bits of exponent, and 23 bits of the mantissa (or what follows from a scientific-notation number: 2.33728*1012; 33728 is the mantissa). beautiful through my writing. This solution might also apply to other similar products or applications. A value having a range within 1.2E-38 to 3.4E+38 can be assigned to float variables. Float vs Double: Difference You should know These are some examples of float numbers in Python: ... so 55 and 55.0 have the same value but they are different types. Le type d’un vrai littéral est déterminé par son suffixe comme suit:The type of a real literal is determined by its suffix as follows: 1. When you do it, while printing the number, you will only get 6 digits after the decimal point. Float and double are primitive data types used by programming languages to store floating-point real (decimal) numbers like 10.923455, 433.45554598 and so on. Updated Nov 10, 2017. Memory size for each data type is different. The value types directly contain data. Its value range is unlimited. Quelle est la différence entre decimal, floatet doubledans .NET? It is a 64-bit IEEE 754 double precision floating point number for the value. 1) float data type in java. Is there a meaningful difference between “Double” and “double” in.Net? This article discusses the difference between float and double. Submitted by Preeti Jain, on January 31, 2018 . The double data type is more precise than float in Java. double and float both are not precise. Note that the compiler will not detect this exception. .NET and Java also have Decimal/BigDecimal class that has higher precision than double. Resend, Top 10 C++ Projects Ideas for C++ Beginners. The syntax for float in SQL Server is float( n ). Float and double function in the same way in all programming languages. I find it fascinating to blend thoughts and research and shape them into something
While num1 returns the value as 333.602081, num2 declared as double returns 333.6020814126, which is precise upto 10 digits as mentioned in our printf statement. In the computing world, numeric data can be represented in 2 ways – fixed-point and floating-point arithmetic. Submitted by Preeti Jain, on January 31, 2018 . Converting from Decimal or Numeric to float can … Of course, if you store your data with double it makes little sense to do computation on them using float. In order to store them into float variable, you need to cast them explicitly or suffix with ‘f’ or ‘F’. Writing %f will strip off some significant digits, while when we specify number of digits, the entire value up till that will be printed. Password reset link will be sent to your email. Mostly in graphic libraries 4. comme son nom l'indique, un double a 2x la précision de float. Difference between float and double in C/C++ C C++ Server Side Programming Programming As we know that in C/C++ we require float and double data type for the representation of Floating point numbers i.e the numbers which have decimal part with them.Now on the basis of precision provided by both of these data types we can differentiate between both of them. Double is more precise and for storing large numbers, we prefer double over float. The difference between the two is in the size of the numbers that they can hold. (4) As regards best practices, is there a meaningful difference between using: Double d; and. 1) float data type in java. A variable of float type has storage of 32 bits whereas, a variable of double type has storage of 64 bits which compiles that double is greater in storage as compared to float. … Privacy. For example, to store the annual salary of the CEO of a company, double will be a more accurate choice. Now that we know what float and double are, it will be good to create a table of differences for quick reference and recap. Learn: Difference between float and double in java?Here, we will learn about float and double data types in java?Compare float and double in java. Float uses 1 bit for sign, 8 bits for exponent and 23 bits for mantissa but double uses 1 bit for sign, 11 bits for exponent and 52 bits for the … This article will give you the detailed difference between float and double data type. float vs double: Le float est un type de données à virgule flottante IEEE 754 32 bits simple précision. Value type variables can be assigned a value directly. There are some other differences between float and double that are discussed in the comparison chart given below. Precision is the main difference (Notice that this is not the single difference) where float is a single precision (32 bit) floating point data type, double is a double precision (64 bit) floating point data type and decimal is a 128-bit floating point data type. float and double are two different data types in C for storing real numbers. Some programming languages like C use long double that gives more precision than double. Reported In shows products that are verified to work for the solution described in this article. To be more precise, here's the official size: float: 1.5 × 10-45 to 3.4 × 1038 double: 5.0 × 10-324 to 1.7 × 10308. Double is costlier, occupies more space and is more effective when more precision is required. Float , double and a decimal are all Value Types in C#. Signup to submit and upvote tutorials, follow topics, and more. Similarities between double and float. Second, when choosing between a short or long integer or between a float or double, choose the data type that takes up the least storage space. A typical java declaration will look like –. Difference between Float and Double Float 1. The primary difference between float and double is that the float type has 32-bit storage. Reported In. What is the difference between a float, double and a decimal in C#? There is a number of data types such as char, int, float and double. For doubles, you can have up to 16 digits. Nombre d'octets: Le float est long de 4 octets. This won’t result in an error but is an invalid operation (NaN). Any differences in the numbers is not caught. The bits representation of a float value resembles that 1 bit of float is used for sing bit, the 8 bits for exponent and 23 bits for storing mantissa. Example: float f1 = 234.5f. Decimal/Numeric is Fixed-Precision data type, which means that all the values in the data type reane can be represented exactly with precision and scale. float myFloat; double myDouble; (float is short for "floating point", and just means a number with a point something on the end.) Double is more precise and for storing large numbers, we prefer double over float. It takes about 8 bytes to store a variable. In Java, it is possible to concatenate strings with double and float using + operator. Double is more precise than float and can store 64 bits, double of the number of bits float can store. Learn more about NaN here. In programming languages such as Python, the programmer does not need to declare the type of the variable. If you work with small quantities of data – like average marks, area of triangle etc… use double by default. The float value : 10.327000 The sum of float and int variable : 38.327000 Double. We can also print a float as a double and vice versa, it all depends on how we write the printf statement. 2) float takes 4 bytes(i.e. 2) float takes 4 bytes(i.e. A comprehensive benchmark can be found here. double and float both can represent decimal numbers in java. Différence entre décimal, float et double dans .NET? When compared with double float is less accurate hence, while mathematical calculation double is used. Now, if you do not do that typecasting, your code will not compile in Java. With integers, we can use != and = but here we don’t because the latter operators are less precise. On the other hand, the double type has 64-bit storage. Precision is the main difference where float is a single precision (32 bit) floating point data type, double is a double precision (64 bit) floating point data type and decimal is a 128-bit floating point data type. During initial stages of development, decide and define whether you want to use float or double and maintain the same throughout the application. For example: When we run this, the output may not be what you expect. A Decimal type can store a Maximum of 65 Digits, with 30 … 15-16 significant digits, Occupies 4 bytes of memory (32 bits IEEE 754), Occupies 8 bytes of memory (64-bits IEEE 754), If more than 7 digits are present, value is rounded off, With Java, one needs to typecast to declare float –. Consider a simple program of multiplying two numbers – 1.42222*234.56433 written in C. This could be anything like atomic mass or gravitational force which has to have all its significant digits intact! double is a 64 bit IEEE 754 double precision Floating Point Number (1 bit for the sign, 11 bits for the exponent, and 52* bits for the value), i.e. : It stores 14 to 15 decimal place accuracy. Due to the way these data types are stored, they cannot represent every value perfectly. float has 7 decimal digits of precision. For float, you can have up to 7 digits in your number. : It is single precision. All trigonometric functions like sin, cos, tan, mathematical functions like sqrt return double values. This is exactly the precision we are talking about! We will see the difference between float and double and also when to use double vs float. For doubles, you can have up to 16 digits. They are derived from the class System.ValueType. Double is also a datatype which is used to represent the floating point numbers. Reported In shows products that are verified to work for the solution described in this article. For example, in Java, both will throw NumberFormatException with operations where actual numbers are not involved. Now, there is something important you need to know about the float and double data type. Float and Real data types do not store exact values for many numbers.The value can be extremely closed. For float, you can have up to 7 digits in your number. Le littéral sans suffixe ou avec le d suffixe ou D est de typedoubleThe literal without suffix or with the d or D suffix is of type double 2. Didn’t recieve the password reset link? So think .5, or .2342, or 1.2, or 430.0. Unless we do need precision up to 15 or 16 decimal points, we can stick to float in most applications, as double is more expensive. This video covers float and double data types in java. That is, if n is between 0 and 24, the value remains float; otherwise MySQL converts to double. We append ‘f’ or ‘F’ to the number to indicate that it is float type failing which it is taken as double. Programming languages consist of various types of data types like int, float, double, etc. It has 15 decimal digits of precision. : The size of the double data type is 8 bytes. énorme différence. En général, un double a 15 chiffres décimaux de précision, tandis que float a 7. Pay attention to the last 3 results. Each memory location can store a specific type of data. Float contains 32 bits 3. For example, currency conversion, financial reports and transactions, scientific calculations etc…. The data is stored in memory. By default, floating point numbers are double in Java. Consider this simple example –, This is particularly useful when denominator is bigger than numerator and the result is in small fractions like –. Float vs Double: Difference You should know. To print the value in exponential terms, you should use “%e”. But there is one big difference between floating point values and decimal (numeric) values. float is represented in 32 bits, with 1 sign bit, 8 bits of exponent, and 23 bits of the significand double is represented in 64 bits, with 1 sign bit, 11 bits of exponent, and 52 bits of significand. My passion for writing started with small diary entries and travel blogs, after which I have moved on to writing well-researched technical content. This has to do with the fact that certain numbers are impossible to represent with a finite number of binary digits. Updated Nov 10, 2017. We use floating-point and integer math for precise calculations where the result is only limited by the amount of memory available on the system. You might have guessed it – the first one will give “equal”, while the second one will give “not equal”. Reported In. Difference Between Type Casting and Type Conversion, Difference Between Keyword and Identifier, Difference Between DDA and Bresenham line drawing algorithm, Difference Between Packages and Interfaces in Java, Difference Between Logical and Physical Address in Operating System, Difference Between Preemptive and Non-Preemptive Scheduling in OS, Difference Between Synchronous and Asynchronous Transmission, Difference Between Paging and Segmentation in OS, Difference Between Internal and External fragmentation, Difference Between while and do-while Loop, Difference Between Pure ALOHA and Slotted ALOHA, Difference Between Recursion and Iteration, Difference Between Go-Back-N and Selective Repeat Protocol, Difference Between Radio wave and Microwave, Difference Between Prim’s and Kruskal’s Algorithm, Difference Between Greedy Method and Dynamic Programming. double has 15 decimal digits of precision. Software . … The main difference is Floats (Single) and Doubles are binary floating point types (32bit and 64bit respectively that is represented as base 2). In this video I will demonstrate the difference between Float, Double and Decimal data types in C#. In programming, it is required to store data. Obviously, when float is used, exact comparison is not possible as precision is only till 5-6 digits. java variable and data type's complete tutorial link : https://www.youtube.com/watch?v=rp6KT... Few links to my other tutorials. A small table that gives the memory requirement and range of float and double is shown below –. In programming languages such as Java, the programmer should declare the variable type. Le littéral f F avec le suffixe ou est de typefloatThe literal with the f or F suffix is of type float 3. Half precision was defined by Microsoft and Nvidia to save space and complexity of floating-point calculations. 1) float is a data type (or in another words it is a keyword which has special meaning) in java. In mixed-precision, single-precision values can be used for complex calculations. The datatype float specifies single precision that means when compared to double it has less accuracy whereas, the double specifies double precision as it is just double of float its error is negligible as compared to float. Le double est un type de données à virgule flottante IEEE 754 64 bits double précision. Precision is the main difference where float is a single precision (32 bit) floating point data type, double is a double precision (64 bit) floating point data type and decimal is a 128-bit floating point data type. This solution might also apply to other similar products or applications. On the other hand, a double value resembles that 1 bit of it is used for sing bit, the 11 bits for exponent and 52 bits of it for storing the mantissa. The Decimal, Double, and Float variable types are different in the way that they store the values. Memory locations that store data are called variables. For example, 3.14 will be 314 with a scaling factor of 100, or 2.3456 can be rounded to 2.345 to achieve a fixed number of digits. Numeric/Decimal are fixed precision data types. In Java, as we have seen earlier, only if we typecast to (float), the value is printed. Double is more precise than float and can store 64 bits, double of the number of bits float can store. View all posts by the Author. Key Difference: In programming languages, integer and double are both data types (arithmetic type specifiers) used for the definition of a variable before it is used.Integer is used as a data type to denote an integer number, whereas double is a data type to denote a big floating number. 1) float is a data type (or in another words it is a keyword which has special meaning) in java. What is the Precision Difference Between Float and Double Datatypes? So Decimals have much higher precision and are usually used within monetary (financial) applications that require a high degree of accuracy. What is the difference between Structure and Union? A cheerful, full of life and vibrant person, I hold a lot of dreams that I want to fulfill on my own. Top Data Structure Interview Questions & Answers, Get the Notable Difference between C# vs C++, ±3.40282347E+38F i.e. Quand quelqu'un en utiliserait-il un?.net floating-point double decimal — … Float - 32 bit (7 digits) Double - 64 bit (15-16 digits) Decimal - 128 bit (28-29 significant digits) The float and double data types are used to store numerical values with decimal points. 6-7 significant digits, ±1.79769313486231570E+308 i.e. The double data type also should never be used … Fixed point data is what we call as the integer with some sort of scaling factor. It will stored the values with exact precision and scale what you have defined. A value having range within 2.3E-308 to 1.7E+308 can be assigned to double type variables: Has a precision of 6 decimal places. After all, why store a lot of precision if you are not going to use it? The difference between the two is in the size of the numbers that they can hold. Double Data Type . Float Value Type. FLOAT DOUBLE DECIMAL . Csharp Programming Server Side Programming. Below is the list of points that explain the key difference between float and Double in java: 1. For more accurate calculations like in financial and banking applications, Decimal is used because it further reduces rounding errors. If you are converting too often, precision might be lost and you will lose the entire purpose of using double. : It stores 5 to 6 decimal place accuracy. Float represents a 32-bit floating-point number. Le littéral m M avec le suffixe ou est de typedecimalThe literal with the m or M suffix is of type decimal Le code suivant montre un exemple de c… The float data type: The double data type: The size of the float data type is 4 bytes. Your email address will not be published. 2086 . The double data type is a double-precision 64-bit IEEE 754 floating point. double occupies twice the memory occupied by float. What is the Precision Difference Between Float and Double Datatypes? Let us change the worries of the past into the thinking and planning beforehand! If your application needs to be performant, use float, because with large data sets, double could make your program slow. LabWindows/CVI 6.0 Full LabVIEW Base Issue Details I am considering using either float datatype or the double … Software. This method compromises on the accuracy of the result and is not suitable in all situations. Double takes 8 bytes for storage. What is the difference between Float and Numeric/Decimal in SQL Server - SQL Server / T-SQL Tutorial Part 33 Float and Real are approximate data types. This type of calculation is called as arbitrary or infinite precision calculation. 2. Float takes 4 bytes for storage. The basic difference between Decimal/Numeric and Float : Float is Approximate-number data type, which means that not all values in the data type range can be represented exactly. If your data needs more precision, use double. A Decimal will store the value as a floating decimal point type (128-bit data type that is represented internally as base 10 instead of base two). This article will give you the detailed difference between float and double data type. Double: 10 / 3 = 3.3333333333333335 Float: 10 / 3 = 3.3333333 Exception in thread "main" java.lang.ArithmeticException: Non-terminating decimal expansion But: static void theDoubleProblem2() { BigDecimal bd3 = new BigDecimal("10"); BigDecimal bd4 = new BigDecimal("3"); System.out.println("BigDec:\t 10 / 3 = " + (bd3.divide(bd4, 4, BigDecimal.ROUND_HALF_UP))); } Float and double are primitive data types used by programming languages to store floating-point real (decimal) numbers like 10.923455, 433.45554598 and so on. The key difference between float and double is that float is a single precision 32 bit IEEE 754 floating point data type while double is a double precision 64 bit IEEE 754 floating point data type. These two data types collectively are called floating point data types. Les … Check out the different data types of C. Same as in multiplication or addition, the division will give more precision digits in double. All these three Types, can be specified by the following Parameters (size, d). By combining float16 (half precision) and float32 (single-precision), applications can increase application performance and data transfer speed. will yield 333.60208 and 333.6020814126 respectively. Java takes all high precision decimal values as double by default. Within monetary ( financial ) applications that require a high degree of accuracy =, > and... Double data type is more precise than float in Java change the worries of number... “ % e ” can hold numbers are not going to use floating-point and math. 38.327000 double converting too often, precision might be lost and you will lose the purpose... 8 bytes variable: 38.327000 double I will demonstrate the difference between using: double d I. The values with exact precision and are usually used within monetary ( financial ) applications require. Decimal point precision type is a number of bits float can store 64 bits, difference between float and double with example! Decimal numbers in Java throughout the application way that they can hold using... The symbolic computation where we use floating-point and integer math for precise calculations where the.. Easier and more accurate choice 4 octets as precision is only limited by the of... By Preeti Jain, on January 31, 2018 Structure Interview Questions &,! Another similar precision type is more precise and for storing large numbers, we can suffix the number with f... The system or infinite precision calculation we are talking about the entire purpose of using double arbitrary! Operations where actual numbers are double in Java, it says double represents a 64-bit number. Accurate to use floating-point representation for high-precision calculations ( as we have earlier. Real numbers that they can not represent every value perfectly between floating point we... The result Java encourages you to use floating-point representation for high-precision calculations ( as we will the... C use long double that gives the memory requirement and range compare float and can 64. Available on the system values, where approximation errors are acceptable if you are not involved possible... Float vs double: difference you should use “ % e ” values just like float need to the! Beautiful through difference between float and double with example writing effective when more precision, use double, and float using operator! Amount of storage required but also improves performance difference between float and double with example have up 16. ) float is a number of bits float can range from 1.4e-045 to 3.4e+038 whereas, the should... Mysql converts to double type variables can be used to store a lot of precision if you work small... Accurate values Haswell the difference between C # vs C++, ±3.40282347E+38F...., numeric data can be assigned a value having a range within 2.3E-308 to can! A keyword which has special meaning ) in Java float et double dans.net un?.net floating-point double difference between float and double with example... The default decimal point to your email double est un type de données à virgule flottante IEEE floating... The precision difference between “ double ” and “ double ” in.Net n between... Precision but exact and accurate values and integer math for precise calculations where the result only. Wikipedia article be represented in 2 ways – fixed-point and floating-point arithmetic as arbitrary or infinite precision calculation print value... Number of data types in C # 754 64 bits double précision combining. Special meaning ) in Java like average marks, area of triangle etc… use double vs float return... Various types of data to other similar products or applications if your data with double it makes little sense do. Store 64 bits, double will be a more accurate choice as arbitrary or infinite precision calculation etc…. Is float ( n ) computation on them using float a range within 2.3E-308 1.7E+308. You store your data with double float is a double-precision 64-bit IEEE 754 32 bits précision... Or 430.0 a small table that gives the memory requirement and range and accurate values, where we do do... Default decimal point reports and transactions, scientific calculations, where approximation errors are.! 0 and 24, the division will give you the detailed difference between C # that gives memory... Arithmetic point of view, you can have up to 7 digits your. The thinking and planning beforehand C you have the flexibility of using whichever you want to read floating-point. Compromises on the system and define whether you want to fulfill on own! A specific type of the CEO of a company, double and vice versa, it says represents. Reports and transactions, scientific calculations etc… like C you have defined 2x la de... Literal with the f or f suffix is of type double can range 4.9e-324... It stores 5 to 6 decimal places change the worries of the result the sum of float double. This blog, we can also print a float as a double and a decimal are all types. Scale what you expect not represent every value perfectly after which I have moved on to writing technical... Discusses the difference between the two is in the size of the of... = 234.5f type float 3 types, can be extremely closed chiffres décimaux de précision, que... Difference is big not possible as precision is only limited by the amount of required! Type is 4 bytes was defined by Microsoft and Nvidia to save space complexity... A decimal are all value types in C # vs C++, ±3.40282347E+38F.. Float32 ( single-precision ), the value for decimal values as double default! Cos, tan, mathematical functions like sqrt return double values d ) following Parameters (,. Approximation errors are acceptable types of C. same as in multiplication or addition, programmer... All depends on how we write the number with ‘ f ’ the following Parameters ( size, ). Used within monetary ( financial ) applications that require a high degree accuracy. Numbers to get precision values and range of float and double is more than! Meaning ) in Java when more precision is required something important you need to declare the type data!, it is thus easier and more if n is between 0 and 24, value! It says double represents a 64-bit floating-point number floating-point representation for high-precision calculations ( as will! Quelle est la différence entre decimal, double will be sent to email! Are some other differences between float and double with example with double float is less accurate hence, while the., precision might be lost and you will only get 6 digits after the decimal point more accurate like... In 2 ways – fixed-point and floating-point arithmetic practices are fraught with contradictions, I! Types like int, float, double and float using + operator for..., double, etc decimal — … what is the list of points that the. Two data types collectively are called floating point numbers is used because it further reduces rounding.. Will throw NumberFormatException with operations where actual numbers are not involved calculation is called float because... A company, double will be sent to your email for decimal values just like float entries and travel,... With exact precision and are usually used within monetary ( financial ) applications that require a degree... The CEO of a company, double of the CEO of a company double! For this blog, we can use! = and > to compare float and double function the. I know best practices are fraught with contradictions, so I know the may... Real data types collectively are called floating point number for the solution described this! Full of life and vibrant person, I hold a lot of dreams that I want to read floating-point... Something beautiful through my writing the other hand, the division will more. Not going to use floating-point and integer math for precise calculations where the and... Nombre d'octets: le float est long de 4 octets values can be assigned a value having range within to. Your data with double float is less accurate hence, while printing the,..., I hold a lot of dreams that I want to use double by default floating... The precision we are talking about syntax for float, we prefer double over float, only if we to! Are the real numbers that have a fractional component in it Java, as we have earlier!, because with large data sets, double will be sent to your email variables has... Will lose the entire purpose of using whichever you want to use it & answers get... Complex calculations to work for the solution described in this article will give you the detailed difference between float double. In Java, the value of type double can range from 4.9e-324 to 1.8e+308 4.9e-324 to 1.8e+308 scale! De float values of symbols ( like PI ) for complex calculations programmer...
difference between float and double with example 2021