This article explains why the range of float is larger than int (same as 4 bytes), but some int is not correctly expressed by float (loss of precision)The precision problem of float and double in Java1. Background KnowledgeIn Java there is no detail,
When declaring, a number of parts of float must be added f/f, while Double does notThe declaration of float will add F if it has a decimal part, otherwise it won't be private. Converts a double type to a float type. float f1 = 1;//ok
Float is a 32-bit, double is 64-bit in C + +, the two are stored in memory and can be expressed in different precision, the current C + + compiler standards are in accordance with the IEEE developed floating-point notation for float,double
650) this.width=650; "title=" osf]4) uext]ob$a$i]y7q9x.png "src=" http://s3.51cto.com/wyfs02/M02/75/82/ Wkiom1y65dgwxdd5aacdjztdkmk204.jpg "alt=" Wkiom1y65dgwxdd5aacdjztdkmk204.jpg "/>Written as a program. fn and F10 into the Debug interface: Select
Don't use float or double for any calculations that require an exact answer.
The float and double types are certainly ill-suited for monetary calculations
Because it is impossible to represent 0.1 (or any other negative power of ten) as a float or
The Int, Char, long, float, and double types of Java are converted to bytes.
16:53:40
Add to favorites I want to contribute
[Font: small and big]
Java codePackage com. util; /**** * file name: COM. Born. util. byteutil.
1. ScopeThe float and double ranges are determined by the number of digits of the index.The float index has eight digits, while the double index has 11 digits. The distribution is as follows:Float:1bit (symbol bit) 8 bits (index bit) 23 bits (tail
An example:int a2 = 7;int b2 = 26;float result2 = b2/a2; The result is 3.0.The result is 3.0, not the expected result: 3.71. This is because the two variables to the right of the equals sign are integer int, and the resulting result is similar to an
Sorry, I used such a "two" question, but I hope the content is not too much.Actually, those who have learned programming are not familiar with these three things. Int is also called an integer. In. net, it refers to int32, which is a 32-bit signed
Why is there no data error for double turn float, but the error of float to double is so great? double d = 3.14; float f = (float) D; System.out.println (f); The output results are:3.14; float f = 127.1f; double d = F;
Floating Point Type:(1)FloatMemory is allocated with 4 bytes, which occupies 32 bits, ranging from 10 ^-38 to 10 ^ 38 and-10 ^ 38 to-10 ^-38For example, float x = 123.456f, y = 2e20f. Note that the data defined by float must end"F"Or" F ", to be
Define a float type variable = 0.7, but the result is 0.69999999 in Il.
Multiply by 10 to obtain the integer. The result is 6. By checking the Il, it is converted to the double type before conversion. It becomes 6.
Demo:
Il:
. Method private
This problem occurs when Access data is exported to DBF. The field width in DBF is not the number of bytes occupied by Access fields, but the number of characters.
This problem occurs when Access data is exported to DBF. The field width in DBF is
Storage Method of Float double type in Computer
How do I store decimals if I only know the binary number of 10 in a computer?
Let's look at floa first.Type:
Float is 4 bytes in the computer (32-bit). Specifically, the first digit is the positive
The following nine lines of code explain the problem:
# Include
Int main (){Float f = 0.01;Int I = 1800;Printf ("% d/n", (int) (f * I ));Printf ("% f/n", f * I );Return 0;}Output:1718.000000When the above program is compiled, a warning:
Short int short integer two byte value range-32768 ~ 32767
The value range of four long integer bytes is-2147483648 ~ 2147483647 float single precision 4 byte value range-3.4*10 (-38 )~ 3.4*10 (38)
Double double 8-byte value range-1.7*10 (-308 )~ 1
During my work, I found a problem with the accuracy of the C # floating point number. The following program running results did not get my expected results:View source
Print?
01
namespace
FloatTest
02
{
03
class
Program
04
{
0
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.