From 536a6480130504b9267e6758075ba1f8df7d9a41 Mon Sep 17 00:00:00 2001 From: Bigsk Date: Sun, 26 Feb 2023 01:00:29 +0800 Subject: [PATCH] real round code for python3 --- half_adjust.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 half_adjust.py diff --git a/half_adjust.py b/half_adjust.py new file mode 100644 index 0000000..c5cd57d --- /dev/null +++ b/half_adjust.py @@ -0,0 +1,3 @@ +half_adjust = lambda n, u=0 : int(n * 10 ** u) / 10 ** u \ + if n * 10 ** u - int(n * 10 ** u) < 0.5 \ + else (int(n * 10 ** u) + 1) / 10 ** u \ No newline at end of file