Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Loading...
Loading...
org.apache.spark.sql.SparkSession$implicits$@79d5f914
+-----+
|value|
+-----+
| 1.12|
| 2.34|
| 9.87|
|  2.5|
|  3.5|
+-----+

null

round

Round to the neart integer and round up at 0.5.

+-----+-----+
|value|round|
+-----+-----+
| 1.12|  1.0|
| 2.34|  2.0|
| 9.87| 10.0|
|  2.5|  3.0|
|  3.5|  4.0|
+-----+-----+

The function round accepts an optional arguments (via method overloadingm) specifying the number of digits to keep.

+-----+-----+
|value|round|
+-----+-----+
| 1.12|  1.1|
| 2.34|  2.3|
| 9.87|  9.9|
|  2.5|  2.5|
|  3.5|  3.5|
+-----+-----+

bround

Round to the nearest integer and round to the even number at 0.5.

+-----+-----+
|value|round|
+-----+-----+
| 1.12|  1.0|
| 2.34|  2.0|
| 9.87| 10.0|
|  2.5|  2.0|
|  3.5|  4.0|
+-----+-----+

+-----+-----+
|value|round|
+-----+-----+
| 1.12|  1.1|
| 2.34|  2.3|
| 9.87|  9.9|
|  2.5|  2.5|
|  3.5|  3.5|
+-----+-----+

rint

The function rint is similar to the function bround.

+-----+-----+
|value|round|
+-----+-----+
| 1.12|  1.0|
| 2.34|  2.0|
| 9.87| 10.0|
|  2.5|  2.0|
|  3.5|  4.0|
+-----+-----+

floor

+-----+-----+
|value|round|
+-----+-----+
| 1.12|    1|
| 2.34|    2|
| 9.87|    9|
|  2.5|    2|
|  3.5|    3|
+-----+-----+

ceil

+-----+-----+
|value|round|
+-----+-----+
| 1.12|    2|
| 2.34|    3|
| 9.87|   10|
|  2.5|    3|
|  3.5|    4|
+-----+-----+