mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8023217: Additional floorDiv/floorMod/multiplyExact methods for java.lang.Math
Add new methods with long, int signatures. Reviewed-by: darcy, scolebourne
This commit is contained in:
parent
1a2c01a37c
commit
3497da36a2
11 changed files with 382 additions and 27 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, 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
|
||||
|
@ -850,7 +850,7 @@ public final class YearMonth
|
|||
long monthCount = year * 12L + (month - 1);
|
||||
long calcMonths = monthCount + monthsToAdd; // safe overflow
|
||||
int newYear = YEAR.checkValidIntValue(Math.floorDiv(calcMonths, 12));
|
||||
int newMonth = (int)Math.floorMod(calcMonths, 12) + 1;
|
||||
int newMonth = Math.floorMod(calcMonths, 12) + 1;
|
||||
return with(newYear, newMonth);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue