• Post Reply Bookmark Topic Watch Topic
  • New Topic
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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

another question form Poddar's questions

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Q 29. What is the output
{
Float f1 = new Float("4.4e99f");
Float f2 = new Float("-4.4e99f");
Double d1 = new Double("4.4e99");
System.out.println(f1);
System.out.println(f2);
System.out.println(d1);
}
a) Runtime error
b) Infinity
-Infinity
4.4E99
c) Infinity
-Infinity
Infinity
d) 4.4E99
-4.4E99
4.4E99
Can anybody tell me how to compute it?
Thanks
 
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you tell the me the poddar's url, if it is not paid mock exam.
 
Ray Chang
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the url is
http://216.33.148.250/cgi-bin/linkrd?_lang=EN&lah=e254c7129ca03a135b69e2ce71357a83&lat=1031943404&hm___action=http%3a%2f%2fwww%2ejavaranch%2ecom%2fmock%2ejsp
you can also find it in javaranch mock exam list.
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
b is correct. You shouldn't know by heart the exact value of Float.MAX_VALUE or Float.MIN_Value but the range for the exponent in base 10 for a float is easy to remember : -38 to 38
Also for a double: -308 to 308
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Float.MAX_VALUE==3.4028234663852886E38f
Float.MIN_VALUE==1.401298464324817E-45f
Double.MAX_VALUE==1.7976931348623157E308d
Double.MIN_VALUE==4.9E-324d
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The range for normalized floats is -38 to 38, and for normalized doubles -308 to 308. But Java floating-point representations apparently allow "denormals" as well, which accounts for the MIN_VALUEs given above.
 
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is a Normal or Denormal Float?
 
reply
    Bookmark Topic Watch Topic
  • New Topic