std-sqrt


Synopsis

(std-sqrt <num>)

Description

Returns the square root of the number, such as the system function sqrt. But the return type maybe a integer number if argument is integer and the resulting square root may be exactly represented as integer. The AutoLISP sqrt always returns a real.

Integer type preservation is more costly than a simple real square root so better use it in output functions but not in fast inner loops.

Exceptional Situations

If the argument is negative the corresponding AutoLISP error is thrown, such as:
ERROR: function undefined for argument: -25.0

Examples

(std-sqrt 2.0)	=> 4.0
(std-sqrt 4)	=> 2
(std-sqrt 4.0)	=> 2.0
(std-sqrt 625)	=> 25

Arguments

num: Any number, if integer or real.

Return Value

A integer or real number.

Side Effects

None.

Module

(std-require 'STDMATH)

Defined in STDMATH