What are java floating point constants
What are java floating point constants
Floating point data type represents real numbers, including decimal parts. Real-world data is complex and requires data types that support real numbers.
1. Floating-point constants Java’s real constants have two representation forms: decimal number form, which consists of numbers and decimal points, and must have a decimal point, such as 0.123, .123, 123., 123.0. 2. Scientific notation form. For example: 123e3 or 123E3, where there must be a number before e or E, and the exponent after e or E must be an integer. Real constants occupy 64 bits in the machine and have double values. For float type values, f or F must be added after the number, such as 12.3F, which occupies 32 bits in the machine and has low representation precision.
Floating point variables have two types: float and double. Float occupies 32 bits, and the value range is 3.4e-038~3.4e 038; while double occupies 64 bits, and the value range is 1.7e-308~1.7e 308. The double type has higher precision and a larger representation range than the float type, and is usually used in scenarios that require high precision, such as scientific calculations.
In Java, you can use float and double to define floating-point variables. For example: float f; // Specify variable f as float type double d; // Specify variable d as double type Unlike C and C, Java does not have an unsigned integer type and specifies the number of memory bytes occupied by integer and floating-point data. This provision ensures the security, robustness and platform independence of Java programs. This means that different Java implementations have consistent behavior when dealing with integer and floating point data, and the results are predictable regardless of the platform they are running on.
java floating point calculation problem
Bit operations are usually used in hardware control. The expression itself cannot determine the specific meaning and needs to be combined with the actual scenario.
& is called "bitwise AND", and its rules are: 0&0=0 1&0=0 0&1=0 1&1=1
"|" is called "bitwise OR", and the operation rules are: 0|0=0 1|0=1 0|1=1 1|1=1
0x7fffff is expressed in 32-bit binary as 0000 0000 0111 1111 1111 1111 1111 1111
According to the bitwise AND operation rule, the high 9 bits of bits are cleared to zero.
0x800000 is expressed in 32-bit binary as 0000 0000 1000 0000 0000 0000 0000 0000
According to the bitwise OR algorithm, the 24th bit is set to 1.
To put it in perspective, ((bits & 0x7fffff)|0x800000) means to clear the high 9 bits of bits first, and then set the 24th bit to 1.
Regarding the first half, "
As for the question mark, there’s no need to explain it, right?
A JAVA question about floating point types
Floating point numbers will have errors after operations, which is normal.
double a=2.00-1.10;
double b=0.90;
System.out.print(a==b);
The result will be false
So sometimes a method is used when judging the equality of floating point numbers, that is
public static boolean isEqual(double a,double b){
final double epsilon=0.00000001;
return Math.abs(a-b) } To sum up, errors will occur after floating point numbers are processed. 0.7799999713897705 is the error caused by converting float to double, and 0.78 is the normal operation of float
The above is the detailed content of What are java floating point constants. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











If you suspect your hard drive encounters issues, you can check the drive for errors on Windows 7. This php.cn post talks about fixdisk Windows 7. You can follow the guide to check the hard drive for errors on Windows 7.

Have you ever encountered a black screen after installing a graphics driver like an Nvidia driver in Windows 10/11? Now in this post from php.cn, you can find a couple of worth trying solutions to the Nvidia driver update black screen.

Windows X-Lite Optimum 11 23H2 Home or Optimum 11 Pro could be your option if you need a custom lite system based on Windows 11 23H2. Go on reading and php.cn will show you how to download Optimum 11 23H2 ISO and install Pro or Home on your PC.

Many SurfaceBook users report that they meet the “core isolation blocked by ew_usbccgpfilter.sys” issue on Windows 11/10. This post from php.cn helps to fix the annoying issue. Keep on your reading.

Tips and Suggestions Notifications is a new design of Windows 11. It will give you suggestions and tips on some new features. But some of you may be bothered by the popup tips. You can read this post from php.cn to learn how to turn off tips and sugg

You must be familiar with the Windows P shortcut if you have more than one monitor. However, the Windows P not working properly might happen occasionally. If you are facing this problem, this post from php.cn can help you indeed.

KB2267602 is a protection or definition update for Windows Defender designed to fix vulnerabilities and threats in Windows. Some users reported that they were unable to install KB2267602. This post from php.cn introduces how to fix the “KB2267602 fai

Data recovery is always a heated topic. To successfully restore data from your device, you should know how it stores data. You can learn the difference between RAID recovery and hard drive recovery from this php.cn post.
