From 5cf9e3af03e343d6668338e3e4512834836a2a93 Mon Sep 17 00:00:00 2001 From: darcy Date: Thu, 14 Apr 2011 21:27:10 -0700 Subject: [PATCH] 6430675: Math.round has surprising behavior for 0x1.fffffffffffffp-2 Reviewed-by: alanb --- src/share/classes/java/lang/Math.java | 31 +++---- src/share/classes/java/lang/StrictMath.java | 20 ++--- test/java/lang/Math/RoundTests.java | 98 +++++++++++++++++++++ 3 files changed, 121 insertions(+), 28 deletions(-) create mode 100644 test/java/lang/Math/RoundTests.java diff --git a/src/share/classes/java/lang/Math.java b/src/share/classes/java/lang/Math.java index 79efeb7e9..5d1be0c21 100644 --- a/src/share/classes/java/lang/Math.java +++ b/src/share/classes/java/lang/Math.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -627,11 +627,9 @@ public final class Math { } /** - * Returns the closest {@code int} to the argument. The - * result is rounded to an integer by adding 1/2, taking the - * floor of the result, and casting the result to type {@code int}. - * In other words, the result is equal to the value of the expression: - *

{@code (int)Math.floor(a + 0.5f)} + * Returns the closest {@code int} to the argument, with ties + * rounding up. + * *

* Special cases: *