summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorCornelius Roemer <cornelius.roemer@gmail.com>2021-12-29 17:14:30 +0100
committerCornelius Roemer <cornelius.roemer@gmail.com>2021-12-29 17:14:30 +0100
commitb6967143e0aff04f2f4b2ae89cea4c4c762bbaf9 (patch)
tree6ffc44d708c2a37e38c55af6f1f529e19d0c0207 /numpy
parent2f41a52d9b2fc70ea2bed6e04de470d854362ccd (diff)
downloadnumpy-b6967143e0aff04f2f4b2ae89cea4c4c762bbaf9.tar.gz
BUG: Remove trailing dec point in dragon4positional
fixes #12441
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/dragon4.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/numpy/core/src/multiarray/dragon4.c b/numpy/core/src/multiarray/dragon4.c
index ce0293615..5d245b106 100644
--- a/numpy/core/src/multiarray/dragon4.c
+++ b/numpy/core/src/multiarray/dragon4.c
@@ -1809,9 +1809,16 @@ FormatPositional(char *buffer, npy_uint32 bufferSize, BigInt *mantissa,
pos--;
numFractionDigits--;
}
- if (trim_mode == TrimMode_LeaveOneZero && buffer[pos-1] == '.') {
- buffer[pos++] = '0';
- numFractionDigits++;
+ if (buffer[pos-1] == '.') {
+ /* in TrimMode_LeaveOneZero, add trailing 0 back */
+ if (trim_mode == TrimMode_LeaveOneZero){
+ buffer[pos++] = '0';
+ numFractionDigits++;
+ }
+ /* in TrimMode_DptZeros, remove trailing decimal point */
+ else if (trim_mode == TrimMode_DptZeros) {
+ pos--;
+ }
}
}