Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #38405
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Has Android different floats? |
| Date | 2018-06-24 17:28 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <pgp2es$ls9$1@dont-email.me> (permalink) |
| References | <pgool7$bru$1@news.albasani.net> <pgor09$19ak$1@gioia.aioe.org> <b4f7eefd-bde4-4b77-9dbf-b417091061ed@googlegroups.com> <90082b6a-1547-4825-83f5-34f0762daad4@googlegroups.com> |
On 6/24/2018 4:35 PM, bursejan@gmail.com wrote:
> The test code would be:
>
> for (int i=22; i<25; i++) {
> System.out.println("Math.pow(10,"+i+")="+Math.pow(10,i));
> }
>
> The result (without strictfp modifier to main()) is:
>
> Math.pow(10,22)=1.0E22
> Math.pow(10,23)=1.0000000000000001E23
> Math.pow(10,24)=1.0E24
>
> The result (with strictfp modifier to main()) is:
>
> Math.pow(10,22)=1.0E22
> Math.pow(10,23)=1.0000000000000001E23
> Math.pow(10,24)=1.0E24
>
> Because invoking Math.pow() is not a basic operator +, *, /, etc..
Have you tried using StrictMath.pow() instead of Math.pow()?
It is certainly possible that the Math implementations are different
on different platforms -- at least, the Javadoc seems to allow such
freedom:
"[...] Code generators are encouraged to use platform-specific
native libraries or microprocessor instructions, where
available, to provide higher-performance implementations of Math
methods. [...]"
It's my understanding, though, that StrictMath implementations on all
platforms are supposed to agree exactly.
--
esosman@comcast-dot-net.invalid
Nine hundred forty-one days to go.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Has Android different floats? j4n bur53 <janburse@fastmail.fm> - 2018-06-24 20:41 +0200
Re: Has Android different floats? Arne Vajhøj <arne@vajhoej.dk> - 2018-06-24 15:21 -0400
Re: Has Android different floats? bursejan@gmail.com - 2018-06-24 13:31 -0700
Re: Has Android different floats? bursejan@gmail.com - 2018-06-24 13:35 -0700
Re: Has Android different floats? bursejan@gmail.com - 2018-06-24 13:44 -0700
Re: Has Android different floats? Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-06-24 17:28 -0400
Re: Has Android different floats? bursejan@gmail.com - 2018-06-24 16:08 -0700
Re: Has Android different floats? bursejan@gmail.com - 2018-06-26 10:29 -0700
csiph-web