Numeric Functions

PL/SQL implements a number of functions that are useful when working with numbers. We list those functions in Table 9-6, and describe each of them in detail in the sections that follow.

Table 9-6. PL/SQL’s built-in numeric functions

Name

Description

ABS

Returns the absolute value of a number.

ACOS

Returns the inverse cosine.

ASIN

Returns the inverse sine.

ATAN

Returns the inverse tangent.

ATAN2

Returns the inverse tangent of a value, but allows you to pass that value differently than when using ATAN.

BITAND

Performs an AND operation on the bits from two positive integer numbers.

CEIL

Returns the smallest integer greater than or equal to the specified number.

COS

Returns the cosine.

COSH

Returns the hyperbolic cosine.

EXP (n)

Returns the number e raised to the nth power, where e = 2.71828183...

FLOOR

Returns the largest integer equal to or less than the specified number.

LN (a)

Returns the natural logarithm of a.

LOG (a, b)

Returns the logarithm, base a, of b.

MOD (a, b)

Returns the remainder of a divided by b.

POWER (a, b)

Returns a raised to the bth power.

ROUND (a, [b])

Returns a rounded to b decimal places.

SIGN (a)

Returns 1 if a is positive, 0 if a is 0, and -1 if a is less than 0 (i.e., negative).

SIN

Returns the sine.

SINH

Returns the hyperbolic sine.

SQRT

Returns the square root of a number.

TAN

Returns the tangent.

TANH

Returns the hyperbolic tangent.

TRUNC (a, [b])

Returns a truncated to b decimal ...

Get Oracle PL/SQL Programming, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.