Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Floating Point Representation (Question)

Reply
Thread Tools

Floating Point Representation (Question)

 
 
Stefan Ram
Guest
Posts: n/a
 
      12-26-2012
AFAIK 0.1 in hex is 0x1.(9)ap-4, where »(9)« means an
infinite sequence of »9«. However, Java only stores a
finite number of 9s:

printf( "%a%n", 0.1 )
0x1.999999999999ap-4

. So, since something /positive/ is missing, Javas
representation of 0.1 should be /smaller/ than 0.1, but

println( new java.math.BigDecimal( 0.1 ))
0.100000000000000005551115123125782702118158340454 1015625

shows me a value that is /greater/ than 0.1?

Removing more 9s makes the value even larger!

println( new java.math.BigDecimal( 0x1.999999999999ap-4 ));
0.100000000000000005551115123125782702118158340454 1015625

println( new java.math.BigDecimal( 0x1.9ap-4 ))
0.10009765625

 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      12-26-2012
Patricia Shanahan <(E-Mail Removed)> writes:
>The "a" in "0x1.999999999999ap-4" is the last digit of the hex fraction.


For some reason, I did not understand this, but thought »ap«
was a unit marking the start of the exponent (already
wondering »Why /two/ letters?«). Now that you have told me
this, I understand it all - thank you!

 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      12-26-2012
On 12/26/2012 11:22 AM, Stefan Ram wrote:
> AFAIK 0.1 in hex is 0x1.(9)ap-4, where »(9)« means an
> infinite sequence of »9«.


What's the "a" for?

> However, Java only stores a
> finite number of 9s:
>
> printf( "%a%n", 0.1 )
> 0x1.999999999999ap-4


"One, point, twelve nines, A, exponent." See the "A?"

--
Eric Sosman
http://www.velocityreviews.com/forums/(E-Mail Removed)d
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Share-Point-2010 ,Share-Point -2010 Training , Share-point-2010Hyderabad , Share-point-2010 Institute Saraswati lakki ASP .Net 0 01-06-2012 06:39 AM
Method to groom a string to floating point representation Alex DeCaria Ruby 15 04-14-2010 03:46 PM
Semi OT: Binary representation of floating point numbers Dilip C Programming 8 12-28-2006 06:36 AM
Unknown floating point representation sergei.s.mikhailov@gmail.com Java 3 06-22-2006 11:54 PM
Binary representation of floating point numbers 63q2o4i02@sneakemail.com Python 10 12-15-2005 03:45 PM



Advertisments