OTX Reference  
OpenTestSystem.Otx.Core.Terms.ToFloat Class Reference

Convert expression to Float More...

Inheritance diagram for OpenTestSystem.Otx.Core.Terms.ToFloat:
Inheritance graph

Public Attributes

Term term
 The expression (term) to be converted to Float More...
 
- Public Attributes inherited from OpenTestSystem.Otx.Core.Terms.Term
MetaData metaData
 Store additional More...
 

Detailed Description

Convert expression to Float

The ToFloat term returns the Float equivalent of the argument. If the argument is Boolean true it returns 1.0 and Boolean false it returns 0.0. If the argument is Integer it returns a Float copy of the value. If the argument is ByteField it returns the Float equivalent according to IEEE 754: 2008 with double precision. If the argument is String it returns the Float value of the string or throws an exception if this is not possible.

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.
  • String
    Returns the float value of the string. The string must correspond to a FloatLiteral. If not, the TypeMismatchException is thrown.
Exceptions
Core.Exceptions.TypeMismatchExceptionIt is thrown in the String case only: if the String does not constitute a float value literal.
Core.Exceptions.OutOfBoundsExceptionIt is thrown in the ByteField case only: if the ByteField's bit-size is neither 32 bit nor 64 bit (i.e. the value cannot be interpreted as single or double precision according to IEEE 754:2019).
Syntax
FloatTerm = ToFloat(Term)
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");

Member Data Documentation

◆ term

Term OpenTestSystem.Otx.Core.Terms.ToFloat.term

The expression (term) to be converted to Float