Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Ron McLeod
• Paul Clapham
• Bear Bibeault
• Junilu Lacar
Sheriffs:
• Jeanne Boyarsky
• Tim Cooke
• Henry Wong
Saloon Keepers:
• Tim Moores
• Stephan van Hulst
• Tim Holloway
• salvin francis
• Frits Walraven
Bartenders:
• Scott Selikoff
• Piet Souris
• Carey Brown

# Floating-Point Literals for Hexadecimal Numbers

Ranch Hand
Posts: 37
Hi,

Can we use floating-point literal for hexadecimals numbers. here is the example:

Output:
x1: 4095
x2: 4095
x3: 65535.0
x4: 65535.0

It is not considering F or D as a suffix. Is there any other way it can use F or D as suffix or it is not possible(which is assume).

Thanks

author
Posts: 23883
142

Matloob Hussain wrote:Hi,

Can we use floating-point literal for hexadecimals numbers. here is the example:

Output:
x1: 4095
x2: 4095
x3: 65535.0
x4: 65535.0

It is not considering F or D as a suffix. Is there any other way it can use F or D as suffix or it is not possible(which is assume).

Try...

Henry

Matloob Hussain
Ranch Hand
Posts: 37

Thanks Henry...............

Matloob

Ranch Hand
Posts: 62
Here F means float and D double , but What is meant by PO here?

Henry Wong
author
Posts: 23883
142

Prashanth Patha wrote:Here F means float and D double , but What is meant by PO here?

It's the hexidecimal floating point literal format. The "P" is used to separate the exponent component. and the zero is the exponent component. So, 0xfffp0f means 0xfff times two to the zero power as a float. We need to use the "p" part, otherwise the "f" will be taken as part of an int literal.

And... the hexidecimal format doesn't use the "e" for exponent, since the "e" can be a valid value in hex too.

Henry

Prashanth Patha
Ranch Hand
Posts: 62
Thank you henry...

Saloon Keeper
Posts: 12259
259
Hey Henry, I've been looking around, but I couldn't find where these literals were described in the JLS. Do you happen to know which paragraph I can read about them?

 Consider Paul's rocket mass heater.