A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z  special characters  sybase-tech-blog


Category: ASE: Functions: Mathematical Functions

round()

The mathematical function round() returns the rounded value of the number declared in the parameter "number". The parameter "decimal_places" specifies the number of digits significant for rounding, before or after the decimal point.

Syntax of the Mathematical Function round()

    round(number, decimal places)
    

The parameter "number" of the Mathematical Function round()

number
The parameter "number" is a placeholder for a number which can be of one of the datatypes numeric, decimal, tinyint, smallint, int, bigint (starting with ASE® version 15.0), float, real, double precision or money. Additionally, the parameter "number" recognises every other datatype which can be converted into one of the required datatypes using implicit conversion.

decimal places
The parameter "decimal places" is a placeholder for a number specifing how many decimal places to round to, i.e. how many digits after the decimal point are significant four rounding. Depending on if the parameter is signed or unsigned, rounding happens either on the right side or the left side of the decimal point. An unsigned parameter value rounds the digits on the right side of the decimal point, a signed parameter rounds the numbers on the left of the decimal point.

Example for the Mathematical Function round()

    select round(124.12345, 2)
go
-----
124.12000

Returns 124.12000.

    select round(124.123456789, 2)
go
-----
124.120000000

Returns 124.120000000.

    select round(124.12345, -2)
go
-----
100.00000

Returns 100.00000.

    select round(124.123456789, -2)
go
-----
100.000000000

Returns 100.000000000.

    select round($124.123, -2)
go
-----
100.00

Returns 100.00.

    select round(124.12, -4)
go
-----
0.00

Returns 0.00.

See also:

ASE T-SQL - Aggregate Functions,
Mathematical Functions,
abs(),
acos(),
asin(),
atan(),
atn2(),
ceiling(),
cos(),
cot(),
degrees(),
exp(),
floor(),
log(),
log10(),
pi(),
power(),
radians(),
rand(),
sign(),
sin(),
sqrt(),
tan().