• 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Doubt with Math class method(s)

 
Ranch Hand
Posts: 274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which code determines the int value foo closest to, but not greater than, a double value bar?
A. int foo = (int) Math.max(bar);
B. int foo = (int) Math.min(bar);
C. int foo = (int) Math.abs(bar);
D. int foo = (int) Math.ceil(bar);
E. int foo = (int) Math.floor(bar);
F. int foo = (int) Math.round(bar);
Ans: E

Doubt: certainly A,b,C,D are wrong. WHY it cannot be F?


pls help
regards,
gitesh
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rounding a number can mean that it returns a number that's greater that the input. If you round 4.7, you get 5.0 .
 
God is a comedian playing for an audience that is afraid to laugh - Voltair. tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic