@@ -75,12 +75,19 @@ nebula> RETURN ceil(9.1);
7575
7676round() returns the rounded value of the specified number. Pay attention to the floating-point precision when using this function.
7777
78- Syntax: ` round(<expression>, <digit >) `
78+ Syntax: ` round(<expression>, <precision>, <mode >) `
7979
8080- ` expression ` : An expression of which the result type is double.
8181
82- - ` digit ` : Decimal digits . If ` digit ` is less than 0, round at the left of the decimal point.
82+ - ` precision ` : An integer specifying the precision . If ` precision ` is less than 0, round at the left of the decimal point.
8383
84+ - ` mode ` : A string specifying the rounding mode. Optional. The following valid values are supported:
85+ - ` DOWN ` : Round towards zero.
86+ - ` CEILING ` : Round towards positive infinity.
87+ - ` FLOOR ` : Round towards negative infinity.
88+ - ` HALF_UP ` : Round towards the closest value of the given precision, with ties being rounded away from zero.
89+ - ` HALF_DOWN ` : Round towards the closest value of the given precision, with ties being rounded towards zero.
90+ - ` HALF_EVEN ` : Round towards the closest value of the given precision, with ties being rounded to the nearest even number.
8491- Result type: Double
8592
8693Example:
@@ -92,12 +99,56 @@ nebula> RETURN round(314.15926, 2);
9299+--------------------+
93100| 314.16 |
94101+--------------------+
102+
95103nebula> RETURN round(314.15926, -1);
96104+-----------------------+
97105| round(314.15926,-(1)) |
98106+-----------------------+
99107| 310.0 |
100108+-----------------------+
109+
110+ nebula> RETURN round(314.15926, 2, "DOWN");
111+ +---------------------------+
112+ | round(314.15926,2,"DOWN") |
113+ +---------------------------+
114+ | 314.15 |
115+ +---------------------------+
116+
117+ nebula> RETURN round(314.15926, 2, "CEILING");
118+ +------------------------------+
119+ | round(314.15926,2,"CEILING") |
120+ +------------------------------+
121+ | 314.16 |
122+ +------------------------------+
123+
124+ nebula> RETURN round(314.15926, 2, "FLOOR");
125+ +----------------------------+
126+ | round(314.15926,2,"FLOOR") |
127+ +----------------------------+
128+ | 314.15 |
129+ +----------------------------+
130+
131+ nebula> RETURN round(314.15, 1, "HALF_UP");
132+ +---------------------------+
133+ | round(314.15,1,"HALF_UP") |
134+ +---------------------------+
135+ | 314.2 |
136+ +---------------------------+
137+
138+ nebula> RETURN round(314.15, 1, "HALF_DOWN");
139+ +-----------------------------+
140+ | round(314.15,1,"HALF_DOWN") |
141+ +-----------------------------+
142+ | 314.1 |
143+ +-----------------------------+
144+
145+ nebula> RETURN round(314.15, 1, "HALF_EVEN");
146+ +-----------------------------+
147+ | round(314.15,1,"HALF_EVEN") |
148+ +-----------------------------+
149+ | 314.2 |
150+ +-----------------------------+
151+
101152```
102153
103154## sqrt()
0 commit comments