D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
Float
/
Filename :
truncate-i.ri
back
Copy
U:RDoc::AnyMethod[iI" truncate:ETI"Float#truncate;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"/Returns +self+ truncated (toward zero) to ;TI"-a precision of +ndigits+ decimal digits.;To:RDoc::Markup::BlankLine o; ; [I"GWhen +ndigits+ is positive, returns a float with +ndigits+ digits ;TI",after the decimal point (as available):;T@o:RDoc::Markup::Verbatim; [I"f = 12345.6789 ;TI" f.truncate(1) # => 12345.6 ;TI""f.truncate(3) # => 12345.678 ;TI"f = -12345.6789 ;TI"!f.truncate(1) # => -12345.6 ;TI"#f.truncate(3) # => -12345.678 ;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.truncate(0) # => 12345 ;TI"f.truncate(-3) # => 12000 ;TI"f = -12345.6789 ;TI" f.truncate(0) # => -12345 ;TI" f.truncate(-3) # => -12000 ;T; 0o; ; [I"BNote that the limited precision of floating-point arithmetic ;TI"$may lead to surprising results:;T@o;; [I"%(0.3 / 0.1).truncate #=> 2 (!) ;T; 0o; ; [I"Related: Float#round.;T: @fileI"numeric.c;T:0@omit_headings_from_table_of_contents_below0I"/truncate(ndigits = 0) -> float or integer ;T0[ I"(*args);T@2FI" Float;TcRDoc::NormalClass00