Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #37951
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | v_borchert@despammed.com (Volker Borchert) |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Can Java 8 do exact arithmetic as in C# |
| Date | 9 Jan 2018 19:48:24 GMT |
| Organization | Private site at Eddersheim, Germany |
| Lines | 27 |
| Distribution | world |
| Message-ID | <p336a8$5il$1@Gaia.teknon.de> (permalink) |
| References | <0ef8b3c0-e45c-4624-a8b8-2bdc67135380@googlegroups.com> <p2vnnj$cqa$1@news.albasani.net> <p2vsgr$2f1$1@dont-email.me> <p30j91$cvc$2@news.albasani.net> <3db83943-14d9-4589-a535-59ccf4b826d3@googlegroups.com> |
| X-Trace | individual.net M4Ing0lRqNTkccsEbxZs9wpct45aLU/V3jSdBh4/en5BQ/qtQE |
| Cancel-Lock | sha1:cyOvoQGS4YfcukpW8FSttsBYD0w= |
| Xref | csiph.com comp.lang.java.programmer:37951 |
Show key headers only | View raw
bursejan@gmail.com wrote:
> On 64-bit CPU, the following shouldn't be that
> costly
Might depend on the actual CPU.
> and is an alternative to the Java code:
>
> int x;
> int y;
> int z;
> long h = (long)x + (long)y;
> if (h < Integer.MIN_VALUE || Integer.MAX_VALUE < h) {
> /* overflow situation */
> } else {
> /* normal situation */
> z = (int)h;
> }
You might want to use non-circuit OR here to reduce the number
of conditional branches to predict.
--
"I'm a doctor, not a mechanic." Dr Leonard McCoy <mccoy@ncc1701.starfleet.fed>
"I'm a mechanic, not a doctor." Volker Borchert <v_borchert@despammed.com>
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