D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Float
/
Filename :
floor-i.ri
back
Copy
U:RDoc::AnyMethod[iI" floor:ETI"Float#floor;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"�Returns a float or integer that is a "floor" value for <code>self</code>, as specified by <code>ndigits</code>, which must be an {integer-convertible object}[rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects].;To; ; [I"}When <code>self</code> is zero, returns a zero value: a float if <code>ndigits</code> is positive, an integer otherwise:;To:RDoc::Markup::Verbatim; [I"Yf = 0.0 # => 0.0 f.floor(20) # => 0.0 f.floor(0) # => 0 f.floor(-20) # => 0 ;T:@format0o; ; [I"�When <code>self</code> is non-zero and <code>ndigits</code> is positive, returns a float with <code>ndigits</code> digits after the decimal point (as available):;To;; [I"�f = 12345.6789 f.floor(1) # => 12345.6 f.floor(3) # => 12345.678 f.floor(30) # => 12345.6789 f = -12345.6789 f.floor(1) # => -12345.7 f.floor(3) # => -12345.679 f.floor(30) # => -12345.6789 ;T;0o; ; [I"�When <code>self</code> is non-zero and <code>ndigits</code> is non-positive, returns an integer value based on a computed granularity:;To:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"7The granularity is <code>10 ** ndigits.abs</code>.;To;;0; [o; ; [I"tThe returned value is the largest multiple of the granularity that is less than or equal to <code>self</code>.;To; ; [I".Examples with positive <code>self</code>:;To:RDoc::Markup::Table:@header[I"ndigits;TI"Granularity;TI"12345.6789.floor(ndigits);T:@align[: right;;: @body[[I"0;TI"1;TI" 12345;T[I"-1;TI"10;TI" 12340;T[I"-2;TI"100;TI" 12300;T[I"-3;TI" 1000;TI" 12000;T[I"-4;TI" 10000;TI" 10000;T[I"-5;TI"100000;TI"0;To; ; [I".Examples with negative <code>self</code>:;To;;[I"ndigits;TI"Granularity;TI"-12345.6789.floor(ndigits);T;[;;;;[[I"0;TI"1;TI"-12346;T[I"-1;TI"10;TI"-12350;T[I"-2;TI"100;TI"-12400;T[I"-3;TI" 1000;TI"-13000;T[I"-4;TI" 10000;TI"-20000;T[I"-5;TI"100000;TI"-100000;T[I"-6;TI"1000000;TI" -1000000;To; ; [I"aNote that the limited precision of floating-point arithmetic may lead to surprising results:;To;; [I"_(0.3 / 0.1).floor # => 2 # Not 3, (because (0.3 / 0.1) # => 2.9999999999999996, not 3.0) ;T;0o; ; [I"Related: Float#ceil.;T: @fileI"numeric.c;T:0@omit_headings_from_table_of_contents_below0I",floor(ndigits = 0) -> float or integer ;T0[ I"(*args);T@zFI" Float;TcRDoc::NormalClass00