• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Floor and ceil methods of math class

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why is that floor and ceil methods of Mathclass take only double as the
datatype and not other data types?

Can anybody please provide the explanation for the above?

Thanks&Cheers
venkat
 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
floor and ceil only take arguments of type double because their purpose is find the nearest integer value either higher than or equal to the argument (ceil) or lower than or equal to the argument (floor). If you were to pass a byte, short, int, or long you would simply get the same result back that you passed in, rendering the method useless. They are not overloaded for float because you can pass a float as the argument where a double is expected, so there is no need for a ceil or floor that takes float.
 
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi venkat

reemember the return type of both floor and ceil is double...

the return type of round and abs is same as the argument type.....

if i am wrong please do correct me..
 
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic