swirl Guide to OmniMark 5   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesOMX VariablesErrors
 
  Related Syntax    
operator   sqrt    

Return type: Opaque
Returns:       

The square root of either a floating point number or BCD number.

For floating point, if x < 0, returns NaN.

For BCD, if x < 0, throws an exception.



Syntax
  define external float function
      sqrt value float x

  define external bcd function
      sqrt value bcd x


Purpose

Use sqrt to calculate the square root of either

You must include either omfloat.xin or ombcd.xin in your program. Decide whether you want BCD mathematics (excellent for financial calculations) or floating point mathematics (excellent for extremely large numbers).

Floating Point Example:


  ; Displays the square root of 144 as a floating point number.
  include "omfloat.xin"
  process
    local float x initial {"144"}
    local float result

    set result to sqrt x
    output "result = " || "d" % result || "%n" 

BCD Example:

  ; Displays the square root of 144 as a BCD number.
  include "ombcd.xin"
  process
    local bcd x initial {"144"}
    local bcd result
    local bcd rounded-result

    set result to sqrt x
    set rounded-result to round result bankers-nearest 0.01
    output "The square root of " || "d" % x || " = " || "d" % rounded-result || "%n"
  ; Output: "The square root of 144 = 12"

If you take the square root of an integer, the result is coerced into the data type of the library you have included - either a floating point or BCD number.

In an OmniMark program, always surround operators with spaces.

    Related Syntax
   exp
   ln
   log10
   **
 
 
----  

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ OMX ] [ OMX ] [ ERRORS ]

Generated: August 11, 2000 at 3:08:01 pm
If you have any comments about this section of the documentation, send email to docerrors@omnimark.com

Copyright © OmniMark Technologies Corporation, 1988-2000.