D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Integer
/
Filename :
round-i.ri
back
Copy
U:RDoc::AnyMethod[iI" round:ETI"Integer#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"4When +ndigits+ is negative, the returned value ;TI"6has at least <tt>ndigits.abs</tt> trailing zeros:;T@o:RDoc::Markup::Verbatim; [ I"!555.round(-1) # => 560 ;TI"!555.round(-2) # => 600 ;TI""555.round(-3) # => 1000 ;TI""-555.round(-2) # => -600 ;TI"555.round(-4) # => 0 ;T:@format0o; ; [I"7Returns +self+ when +ndigits+ is zero or positive.;T@o;; [I"555.round # => 555 ;TI"555.round(1) # => 555 ;TI"555.round(50) # => 555 ;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"*25.round(-1, half: :up) # => 30 ;TI"+(-25).round(-1, half: :up) # => -30 ;T; 0o;;0; [o; ; [I" +:down+: round toward zero:;T@o;; [I"*25.round(-1, half: :down) # => 20 ;TI"+(-25).round(-1, half: :down) # => -20 ;T; 0o;;0; [o; ; [I"J+:even+: round toward the candidate whose last nonzero digit is even:;T@o;; [I"*25.round(-1, half: :even) # => 20 ;TI"*15.round(-1, half: :even) # => 20 ;TI"+(-25).round(-1, half: :even) # => -20 ;T; 0o; ; [I"=Raises and exception if the value for +half+ is invalid.;T@o; ; [I"Related: Integer#truncate.;T: @fileI"numeric.c;T:0@omit_headings_from_table_of_contents_below0I"-round(ndigits= 0, half: :up) -> integer ;T0[ I"(p1 = v1, p2 = {});T@LFI"Integer;TcRDoc::NormalClass00