Difference between revisions of "SHIP:Sail:ftoi"

From Serious Documentation
Jump to: navigation, search
(Detailed Description)
(Examples)
Line 33: Line 33:
 
! scope="col" style="text-align:left" | Notes
 
! scope="col" style="text-align:left" | Notes
 
|-
 
|-
|<code>{{SailFunc|ceil}}(-5.1f);</code> || -5 ||
+
|<code>{{SailFunc|ftoi}}(-5.1f);</code> || -5 ||
 
|-
 
|-
|<code>{{SailFunc|ceil}}(5.2f);</code> || 6 ||
+
|<code>{{SailFunc|ftoi}}(5.2f);</code> || 5 ||
 
|}
 
|}

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
ftoi(-5.1f); -5
ftoi(5.2f); 5