• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hexadecimal floating-point literals

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15205
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Posts: 48374
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I never actually understood this one... I suppose some day it could come in handy?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic