Difference between revisions of "SHIP:Sail:ftoi"

From Serious Documentation
Jump to: navigation, search
(Created page with "__NOTOC__ {{SailFuncTableStart|}}<onlyinclude> |{{SailFunc|ftoi}}||{{DataType|Integer}}||1||Casts a {{DataType|Float}} to an {{DataType|Integer}}</onlyinclude> |} == See Also:...")
 
(Detailed Description)
Line 25: Line 25:
 
== Detailed Description ==
 
== Detailed Description ==
  
The <code>{{SailFunc|ftoi}}()</code> 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 <code>{{SailFunc|ftoi}}({{SailFunc|round}}(x)</code>.  
+
The <code>{{SailFunc|ftoi}}()</code> 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 <code>{{SailFunc|ftoi}}({{SailFunc|round}}(x))</code>.
  
 
== Examples ==
 
== Examples ==

Revision as of 06:33, 22 June 2014

Function Returns Introduced Description
ftoi Integer 1 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
ceil(-5.1f); -5
ceil(5.2f); 6