File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Letter 'e; in assigning value to float 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 » Beginning Java
Bookmark "Letter Watch "Letter New topic
Author

Letter 'e; in assigning value to float

Phal Ach
Ranch Hand

Joined: May 09, 2008
Posts: 54
float a = 1.1e1f;
In this line variable a is assigned value 11.0. Can anybody please explain me how? Thanks
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

The notation

N.NEM

is called "scientific" or "exponential" notation. The E is a separator. The numbers to the left of the E are called the "mantissa", and the numbers to th e right are the "exponent". The value of the whole expression is the product of the mantissa times ten raised to the power of the exponent. Since 10 to the first power is ten, and 1.1 times ten is eleven, the value of the expression is 11.0 .

Obviously there's no reason why you'd ever write eleven in this format -- but it sure is convenient if you need to write 123 trillion!


[Jess in Action][AskingGoodQuestions]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

the 'e' refers to 'exponent'

"1.1e1f" means

'take 1.1 and multiply it by 10^1"

"1.827e9f" means

take 1.827 and multiply it by 10^9, giving 1,827,000,000


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Phal Ach
Ranch Hand

Joined: May 09, 2008
Posts: 54
Thank you very much Ernest Friedman-Hill and Fred Rosenberger. I was not able to find this explanation anywhere and it helped me a lot. Thanks a bunch.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Letter 'e; in assigning value to float
 
Similar Threads
question on wrapper class
Float wrapper takes double primitive implicitly.
Tech Word Game
WA #2 ..... word association
string to float conversion round off problem