Difference between revisions of "SHIP:Sail:dtoi"

From Serious Documentation
Jump to: navigation, search
(Created page with "__NOTOC__ {{SailFuncTableStart|}}<onlyinclude> |{{SailFunc|dtoi}}||{{DataType|Integer}}||style="text-align:center;"|v5.0||Casts a {{DataType|Double}} to an {{DataType|Integer}...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
{{SailFuncTableStart|}}<onlyinclude>
 
{{SailFuncTableStart|}}<onlyinclude>
|{{SailFunc|dtoi}}||{{DataType|Integer}}||style="text-align:center;"|v5.0||Casts a {{DataType|Double}} to an {{DataType|Integer}} {{v5}}</onlyinclude>
+
|{{SailFunc|dtoi}}||{{DataType|Integer}}||style="text-align:center;"|v5.0||Casts a {{DataType|Double}} to an {{DataType|Integer}}</onlyinclude>
 
|}
 
|}
 
== See Also: ==
 
== See Also: ==
Line 34: Line 34:
 
! scope="col" style="text-align:left" | Notes
 
! scope="col" style="text-align:left" | Notes
 
|-
 
|-
|<code>{{SailFunc|dtoi}}(-5.1d);</code> || -5 ||
+
|<code>{{SailFunc|dtoi}}(-5.1);</code> || -5 ||
 
|-
 
|-
|<code>{{SailFunc|dtoi}}(5.2d);</code> || 5 ||
+
|<code>{{SailFunc|dtoi}}(5.2);</code> || 5 ||
 
|}
 
|}
 +
 +
[[Category:Numeric Functions]]

Latest revision as of 17:05, 13 October 2016

Function Returns Introduced Description
dtoi Integer v5.0 Casts a Double to an Integer

See Also:

Prototype

Integer ftoi(Double n);

Parameters/Return Value

Parameter Data Type Description
n Double the number to find the ceiling value of
Return Double the integer portion of the supplied number

Detailed Description

The dtoi() function returns the returns the integer portion of the supplied double precision floating point number. Note this is a truncating conversion (as in Java and C), not a rounding conversion. Often, you'll want to use rounding as well, for example dtoi(round(x)).

Examples

Example Result Notes
dtoi(-5.1); -5
dtoi(5.2); 5