Skip to Content

Find floor value of a number using Math.floor

  • strict warning: Non-static method view::load() should not be called statically in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/views.module on line 906.
  • strict warning: Declaration of views_handler_argument::init() should be compatible with views_handler::init(&$view, $options) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_argument.inc on line 0.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_filter.inc on line 0.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_filter.inc on line 0.
  • strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_filter_boolean_operator.inc on line 0.
  • strict warning: Declaration of views_plugin_style_default::options() should be compatible with views_object::options() in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/plugins/views_plugin_style_default.inc on line 0.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/plugins/views_plugin_row.inc on line 0.
  • strict warning: Declaration of views_plugin_row::options_submit() should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/plugins/views_plugin_row.inc on line 0.

  1. /*
  2.   Find floor value of a number using Math.floor
  3.   This java example shows how to find a floor value of a number using floor method
  4.   of Java Math class. floor method returns the largest interger which is not grater
  5.   than the value.
  6. */
  7.  
  8. public class FindFloorValueExample {
  9.  
  10.   public static void main(String[] args) {
  11.    
  12.     /*
  13.      * To find a floor value, use
  14.      * static double floor(double d) method of Math class.
  15.      *
  16.      * It returns a largest integer which is not grater than the argument value.
  17.      */
  18.    
  19.     //Returns the same value
  20.     System.out.println(Math.floor(70));
  21.    
  22.     //returns largest integer which is not less than 30.1, i.e. 30
  23.     System.out.println(Math.floor(30.1));
  24.    
  25.     //returns largest integer which is not less than 15.5, i.e. 15
  26.     System.out.println(Math.floor(15.5));
  27.    
  28.     //in this case it would be -40
  29.     System.out.println(Math.floor(-40));
  30.    
  31.     //it returns -43.
  32.     System.out.println(Math.floor(-42.4));
  33.    
  34.     //returns 0
  35.     System.out.println(Math.floor(0));
  36.    
  37.   }
  38. }
  39.  
  40. /*
  41. Output would be
  42. 70.0
  43. 30.0
  44. 15.0
  45. -40.0
  46. -43.0
  47. 0.0
  48. */