D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Float
/
Filename :
round-i.ri
back
Copy
U:RDoc::AnyMethod[iI" round:ETI"Float#round;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"6Returns +self+ rounded to the nearest value with ;TI"-a precision of +ndigits+ decimal digits.;To:RDoc::Markup::BlankLine o; ; [I"DWhen +ndigits+ is non-negative, returns a float with +ndigits+ ;TI",after the decimal point (as available):;T@o:RDoc::Markup::Verbatim; [I"f = 12345.6789 ;TI"f.round(1) # => 12345.7 ;TI"f.round(3) # => 12345.679 ;TI"f = -12345.6789 ;TI"f.round(1) # => -12345.7 ;TI" f.round(3) # => -12345.679 ;T:@format0o; ; [I"4When +ndigits+ is negative, returns an integer ;TI"7with at least <tt>ndigits.abs</tt> trailing zeros:;T@o;; [I"f = 12345.6789 ;TI"f.round(0) # => 12346 ;TI"f.round(-3) # => 12000 ;TI"f = -12345.6789 ;TI"f.round(0) # => -12346 ;TI"f.round(-3) # => -12000 ;T; 0o; ; [I"*If keyword argument +half+ is given, ;TI">and +self+ is equidistant from the two candidate values, ;TI"9the rounding is according to the given +half+ value:;T@o:RDoc::Markup::List: @type:BULLET:@items[o:RDoc::Markup::ListItem:@label0; [o; ; [I"*+:up+ or +nil+: round away from zero:;T@o;; [I"&2.5.round(half: :up) # => 3 ;TI"&3.5.round(half: :up) # => 4 ;TI"'(-2.5).round(half: :up) # => -3 ;T; 0o;;0; [o; ; [I" +:down+: round toward zero:;T@o;; [I"&2.5.round(half: :down) # => 2 ;TI"&3.5.round(half: :down) # => 3 ;TI"'(-2.5).round(half: :down) # => -2 ;T; 0o;;0; [o; ; [I"J+:even+: round toward the candidate whose last nonzero digit is even:;T@o;; [I"&2.5.round(half: :even) # => 2 ;TI"&3.5.round(half: :even) # => 4 ;TI"'(-2.5).round(half: :even) # => -2 ;T; 0o; ; [I"=Raises and exception if the value for +half+ is invalid.;T@o; ; [I"Related: Float#truncate.;T: @fileI"numeric.c;T:0@omit_headings_from_table_of_contents_below0I"7round(ndigits = 0, half: :up) -> integer or float ;T0[ I"(p1 = v1, p2 = {});T@SFI" Float;TcRDoc::NormalClass00