Difference between revisions of "SHIP:Sail:ftoi"

From Serious Documentation
Jump to: navigation, search
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 
{{SailFuncTableStart|}}<onlyinclude>
 
{{SailFuncTableStart|}}<onlyinclude>
|{{SailFunc|ftoi}}||{{DataType|Integer}}||1||Casts a {{DataType|Float}} to an {{DataType|Integer}} {{v5}}</onlyinclude>
+
|{{SailFunc|ftoi}}||{{DataType|Integer}}||style="text-align:center;"|v5.0||Casts a {{DataType|Float}} to an {{DataType|Integer}}</onlyinclude>
 
|}
 
|}
This function was introduced in SHIP Version 5.0.
 
 
== See Also: ==
 
== See Also: ==
*[[SHIP:Sail|SHIP Sail Home]]
+
*[[SHIP:Sail|Sail Home]]
*[[SHIP:Sail:Functions|SHIP Sail Function Home]]
+
*[[SHIP:Sail:Functions|Sail Functions]]
*{{SailFunc|abs}}, {{SailFunc|ceil}}, {{SailFunc|floor}}, {{SailFunc|ftoi}}, {{SailFunc|itof}}, {{SailFunc|max}}, {{SailFunc|min}}, {{SailFunc|round}}
+
*[[SHIP:Sail:Numeric Functions|Sail Numeric Functions]]
 +
*{{SailFunc|abs}}, {{SailFunc|ceil}}, {{SailFunc|floor}}, {{SailFunc|itof}}, {{SailFunc|max}}, {{SailFunc|min}}, {{SailFunc|round}}
 
== Prototype ==
 
== Prototype ==
 
<code>{{DataType|Integer}} {{SailFunc|ftoi}}({{DataType|Float}} n);</code>
 
<code>{{DataType|Integer}} {{SailFunc|ftoi}}({{DataType|Float}} n);</code>
Line 38: Line 38:
 
|<code>{{SailFunc|ftoi}}(5.2f);</code> || 5 ||
 
|<code>{{SailFunc|ftoi}}(5.2f);</code> || 5 ||
 
|}
 
|}
 +
 +
[[Category:Numeric Functions]]

Latest revision as of 17:24, 13 October 2016

Function Returns Introduced Description
ftoi Integer v5.0 Casts a Float to an Integer

See Also:

Prototype

Integer ftoi(Float n);

Parameters/Return Value

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

Detailed Description

The ftoi() function returns the returns the integer portion of the supplied 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 ftoi(round(x)).

Examples

Example Result Notes
ftoi(-5.1f); -5
ftoi(5.2f); 5