Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37944
| Path | csiph.com!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | Arne Vajhøj <arne@vajhoej.dk> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Can Java 8 do exact arithmetic as in C# |
| Date | Mon, 8 Jan 2018 20:04:56 -0500 |
| Organization | Aioe.org NNTP Server |
| Lines | 49 |
| Message-ID | <p314fm$1lag$1@gioia.aioe.org> (permalink) |
| References | <0ef8b3c0-e45c-4624-a8b8-2bdc67135380@googlegroups.com> |
| NNTP-Posting-Host | PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Complaints-To | abuse@aioe.org |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 |
| X-Notice | Filtered by postfilter v. 0.8.2 |
| Content-Language | en-US |
| Xref | csiph.com comp.lang.java.programmer:37944 |
Show key headers only | View raw
On 1/8/2018 7:17 AM, bursejan@gmail.com wrote:
> Java 8 has a nice feature, maybe this
> isn't known very well. But there are
>
> a couple of new operations in Math:
>
> /**
> * Returns the sum of its arguments,
> * throwing an exception if the result overflows an {@code int}.
> *
> * @param x the first value
> * @param y the second value
> * @return the result
> * @throws ArithmeticException if the result overflows an int
> * @since 1.8
> */
> public static int addExact(int x, int y);
>
> /**
> * Returns the sum of its arguments,
> * throwing an exception if the result overflows a {@code long}.
> *
> * @param x the first value
> * @param y the second value
> * @return the result
> * @throws ArithmeticException if the result overflows a long
> * @since 1.8
> */
> public static long addExact(long x, long y);
Nice.
But probably of limited value.
The programmers calling these methods do so because
they are aware of the risk of overflow.
If these methods did not exist they would still be
aware and (hopefully) do something else to handle
the problem.
The problem is the programmers not aware of the
risk of overflow.
And these methods does not help them.
Arne
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Can Java 8 do exact arithmetic as in C# bursejan@gmail.com - 2018-01-08 04:17 -0800
Re: Can Java 8 do exact arithmetic as in C# j4n bur53 <janburse@fastmail.fm> - 2018-01-08 13:21 +0100
Re: Can Java 8 do exact arithmetic as in C# Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-01-08 08:42 -0500
Re: Can Java 8 do exact arithmetic as in C# j4n bur53 <janburse@fastmail.fm> - 2018-01-08 21:11 +0100
Re: Can Java 8 do exact arithmetic as in C# bursejan@gmail.com - 2018-01-08 18:08 -0800
Re: Can Java 8 do exact arithmetic as in C# bursejan@gmail.com - 2018-01-08 18:22 -0800
Re: Can Java 8 do exact arithmetic as in C# v_borchert@despammed.com (Volker Borchert) - 2018-01-09 19:48 +0000
Re: Can Java 8 do exact arithmetic as in C# Arne Vajhøj <arne@vajhoej.dk> - 2018-01-08 20:04 -0500
Re: Can Java 8 do exact arithmetic as in C# bursejan@gmail.com - 2018-01-08 17:53 -0800
csiph-web