addaptic

Reference Powers and roots

lz_root_2

The square root.

long lz_root_2( CLZNumber* leftOperand, CLZNumber* targetNumber = nullptr );

Correctly rounded, by Newton–Raphson, and at wide widths by the arithmetic-geometric mean's own square root. A root that ends is answered short: the square root of 0.0001 is 0.01. A value exactly on a half is decided exactly.

The root of a negative number is refused, kFailed, flagged not-a-number; lzc_root_2 gives the complex one.

Examples

CallAnswerReturns
lz_root_2( 2 )1.414213562373095048801688724209698079kNoError
lz_root_2( 2 ) 50 places1.41421356237309504880168872420969807856967187537695kNoError
lz_root_2( 0.0001 )0.01kNoError
lz_root_2( −9 )not a numberkFailed

Each answer is what Addaptic printed for the call, at 36 places unless a setting is shown.

Returns

kNoError (0) when the answer is written. Otherwise an error code, with the answer flagged infinite or not-a-number; see Errors and flags.

See also

  • lz_root_3 The cube root.
  • lz_root_n The root of the left number whose order is the right.
  • lzc_root_2 The principal square root of a complex number.