From ef1f142cde96a09842e0a2ed3c9776a264ea2f11 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Tue, 2 Jul 2024 00:14:28 +0200 Subject: [PATCH] Issue #2531 - Adjust rounding in toExponential (and kin) to round up at midpoint. Resolves #2531 --- js/src/dtoa.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/src/dtoa.c b/js/src/dtoa.c index 1df01cc2ae..5d18f8c1e2 100644 --- a/js/src/dtoa.c +++ b/js/src/dtoa.c @@ -1,9 +1,10 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /**************************************************************** * - * The author of this software is David M. Gay. + * The original author of this software is David M. Gay. * * Copyright (c) 1991, 2000, 2001 by Lucent Technologies. + * Copyright (c) 2024 by Moonchild Productions. * * Permission to use, copy, modify, and distribute this software for any * purpose without fee is hereby granted, provided that this entire notice @@ -2958,7 +2959,7 @@ dtoa } #endif dval(d) += dval(d); - if (dval(d) > ds || (dval(d) == ds && L & 1)) { + if (dval(d) >= ds) { bump_up: while(*--s == '9') if (s == s0) {