File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Hexadecimal floating-point literals Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Hexadecimal floating-point literals" Watch "Hexadecimal floating-point literals" New topic
Author

Hexadecimal floating-point literals

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13869
    
  10

I've been programming in Java for more than 10 years, so I thought I knew the language inside out, but I just discovered a new, obscure feature: you can write floating-point constants in hexadecimal.

You can for example write: 0x50.1p3 which is equal to 640.5.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
I never knew that, but it's in the Java™ Language Specification that you can use p/P as an exponent indicator.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Yeah, I never actually understood this one... I suppose some day it could come in handy?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hexadecimal floating-point literals
 
Similar Threads
Help with using Buffered Reader and if statements
Double
Single precision /double precision?
Compiling errata for K&B, SCJP 6
Replacing characters in a string?