[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.2.6.6 Conversion Between Data Types

(This message will disappear, once this node revised.)

The unary negation operand is always converted to integer type:

 
-(1 + 1)  => -2
-(127.0.0.1 + 2) => -2130706435
- ("1" + "1") => -11
- "text" error--> cannot convert string to integer

The unary not operand is converted using the following rules:

  1. If the operand is integer, no conversion is performed.
  2. If the operand is STRNUM (see STRNUM) or ipaddr, it is converted to integer.
  3. If the operand is string (but is not STRNUM), the result of not is true only if the operand is an empty string.
  4. If the operand is avl, the result of not is true if the list is empty.

Examples:

 
not 0 => 1
not 10 => 0
not "23" => 0
not "0" => 1
not "text" => 0
not "" => 1
not 127.0.0.1 => 0
not 0.0.0.0 => 1

When operands of two different data types are used in a binary operation, one of the operands is converted (cast) to another operand's type according to the following rules:

  1. If one of the operands is literal, radtest attemtps to convert another operand to the literal data type. If this attempt fails, it goes on to rule 2.
  2. If one of operands is STRNUM (see STRNUM) and another is of numeric data type (i.e. either integer or ipaddr), the latter is converted to string representation.
  3. If one of the operands is ipaddr and another is integer, the latter is converted to ipaddr.
  4. Otherwise, if one of the operands is string, the second operand is also converted to string.
  5. Otherwise, the two operands are incompatible. Radtest prints appropriate diagnostics and aborts execution of the current statement.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Sergey Poznyakoff on November, 20 2004 using texi2html