Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Regarding unsigned double value

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

Regarding the link given by one of the rancher http://www.geocities.com/sahirshah/applets/mocktest.html
as i was solving one problem which says

System.out.println(""+(10/-0.0))

the answer given was INFINITY (positive)
but when i compiled it , it gave INFINITY (negative)
plz reply
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Negative infinity is the expected result because the numerator is positive. As x approaches zero from the negative side of zero, 10.0/x is always negative and getting bigger and bigger.

Conclusion: the mock exam's answer is wrong.
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
10/-0.0 expression is promoted to a floating expression. In a floating expression, the sign counts even for zero.

So, dinaminotor makes (-0.0) the resultant sign to be negative.
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!