Difference between revisions of "Core.Terms.ToFloat"

From emotive
Jump to navigation Jump to search
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{DISPLAYTITLE:OTX '''ToFloat'''}}[[Category:Core]]
 
{{DISPLAYTITLE:OTX '''ToFloat'''}}[[Category:Core]]
 
== Classification ==
 
== Classification ==
{{ClassificationActivity | ToFloat | To convert an expression to a Float | [[Term]] | [[Core|OTX Core library]] | [[Conversion terms]] | - | - }}
+
{{ClassificationActivity | ToFloat | Converts an OTX term to a value of the Float data type | [[Term]] | [[Core|OTX Core library]] | [[Conversion terms]] | [[Core.DataTypes.ComplexDataType.OutOfBoundsException|OutOfBoundsException]]<br />[[Core.DataTypes.ComplexDataType.TypeMismatchException|TypeMismatchException]] | - }}
  
 
== Pseudo-Code Syntax ==
 
== Pseudo-Code Syntax ==
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
FLoatTerm = COnversion.ToFloat(Term);
+
FLoatTerm ToFloat(Term)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
== Description ==
 
== Description ==
Term to the convert an expression to a Float.
+
This term will return the Float counterpart of the argument term.
  
{{TermReturnValue| [[Core.DataTypes.SimpleDataType.Float|Float]] | Return value of the appropriate type.}}
+
{{TermReturnValue| [[Core.DataTypes.SimpleDataType.Float|Float]] | Returns the Float counterpart of the argument term.}}
  
 
== Rules ==
 
== Rules ==
 
* '''Boolean'''
 
* '''Boolean'''
*: Returns 1.0, if {{FontColor|blue||true}}, otherwise 0.0
+
*: Returns 1.0, if {{FontColor|blue||true}}, otherwise 0.0 .
 
* '''Integer'''
 
* '''Integer'''
*: Returns a float copy of the value
+
*: Returns a float copy of the value.
 
* '''Float'''
 
* '''Float'''
*: Returns a copy of the value
+
*: Returns a copy of the value.
 
* '''ByteField'''
 
* '''ByteField'''
*: Returns the float value of the ByteFields. The interpretation according to '''IEEE 754:1985'''.
+
*: Returns the float value of the ByteFields (interpretation according to [http://www.dsc.ufcg.edu.br/~cnum/modulos/Modulo2/IEEE754_2008.pdf '''IEEE 754:2008''']).
 
* '''String'''
 
* '''String'''
*: Returns the float value of the string. The string must correspond to a [[Core.Terms.FloatLiteral|FloatLiteral]]. If not, an exception is thrown.
+
*: Returns the float value of the string. The string must correspond to a [[Core.Terms.FloatLiteral|FloatLiteral]]. If not, the TypeMismatchException is thrown.
  
 
== Properties ==
 
== Properties ==
 
{| {{TableHeader}}
 
{| {{TableHeader}}
 
{{TableRowPropertiesHeader}}
 
{{TableRowPropertiesHeader}}
{{TableRowPropertie1| Term | - | [[Term]] | - | [1] | The expression to be converted. Rules, see description.}}
+
{{TableRowPropertie1| Term | - | [[Term]] | - | [1] | Represents the OTX term that will be converted to a new value of the Float data type. See conversion rule descriptions above.}}
 
|}
 
|}
  
 
== Examples ==
 
== Examples ==
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 
<syntaxhighlight lang="java" enclose="div" style="font-size: medium;">
 +
/// Local Declarations
 +
 
Float Float1;
 
Float Float1;
 
Float Float2;
 
Float Float2;
 
Float Float3;
 
Float Float3;
 
Float Float4;
 
Float Float4;
 +
Float Float5;
 +
 +
/// Flow
  
Float1 = Conversion.ToFloat(true);
+
Float1 = ToFloat(true);
Float2 = Conversion.ToFloat("1234");
+
Float2 = ToFloat(123);
Float3 = Conversion.ToFloat(123);
+
Float3 = ToFloat(123.456);
Float4 = Conversion.ToFloat(&18 00 FF FF);
+
Float4 = ToFloat(&18 00 FF FF);
 +
Float5 = ToFloat("123.456");
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Latest revision as of 03:08, 7 May 2019

Classification

Name ToFloat
Short Description Converts an OTX term to a value of the Float data type
Class Term
Extension OTX Core library
Group Conversion terms
Exceptions OutOfBoundsException
TypeMismatchException
Checker Rules -
Standard Compliant Yes

Pseudo-Code Syntax

FLoatTerm ToFloat(Term)

Description

This term will return the Float counterpart of the argument term.

Return Value

The Term returns the value, see table below.

Icons Note.png In OTX, Terms are categorized according to its return data type!
Data Type Description
Float Returns the Float counterpart of the argument term.

Rules

  • Boolean
    Returns 1.0, if true , otherwise 0.0 .
  • Integer
    Returns a float copy of the value.
  • Float
    Returns a copy of the value.
  • ByteField
    Returns the float value of the ByteFields (interpretation according to IEEE 754:2008).
  • String
    Returns the float value of the string. The string must correspond to a FloatLiteral. If not, the TypeMismatchException is thrown.

Properties

Name Data Type Class Default Cardinality Description
Term - Term - [1] Represents the OTX term that will be converted to a new value of the Float data type. See conversion rule descriptions above.

Examples

/// Local Declarations

Float Float1;
Float Float2;
Float Float3;
Float Float4;
Float Float5;

/// Flow

Float1 = ToFloat(true);
Float2 = ToFloat(123);
Float3 = ToFloat(123.456);
Float4 = ToFloat(&18 00 FF FF);
Float5 = ToFloat("123.456");

See also

ToBoolean
ToInteger
ToByteField
ToString