Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38415

Re: Has Android different floats?

From "Eric Sosman" <eric.sosman@1:261/38.remove-101j-this>
Newsgroups comp.lang.java.programmer
Subject Re: Has Android different floats?
Date 2018-06-24 17:28 -0500
Organization Agency News - Dunedin, New Zealand
Message-ID <5B324677.1154.ucljprogr@castlerockbbs.com> (permalink)
References <5B324677.1152.ucljprogr@castlerockbbs.com>

Show all headers | View raw


  To: bursejan
From: Eric Sosman <esosman@comcast-dot-net.invalid>

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.

--- BBBS/Li6 v4.10 Toy-3
 * Origin: Prism bbs (1:261/38)

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Has Android different floats? "j4n bur53" <j4n.bur53@1:261/38.remove-101j-this> - 2018-06-24 20:41 -0500
  Re: Has Android different floats? "Arne Vajhøj" <arne vajhøj@1:261/38.remove-101j-this> - 2018-06-24 15:21 -0500
    Re: Has Android different floats? "bursejan" <bursejan@1:261/38.remove-101j-this> - 2018-06-24 13:31 -0500
      Re: Has Android different floats? "bursejan" <bursejan@1:261/38.remove-101j-this> - 2018-06-24 13:35 -0500
        Re: Has Android different floats? "bursejan" <bursejan@1:261/38.remove-101j-this> - 2018-06-24 13:44 -0500
        Re: Has Android different floats? "Eric Sosman" <eric.sosman@1:261/38.remove-101j-this> - 2018-06-24 17:28 -0500
          Re: Has Android different floats? "bursejan" <bursejan@1:261/38.remove-101j-this> - 2018-06-24 16:08 -0500
            Re: Has Android different floats? "bursejan" <bursejan@1:261/38.remove-i5b-this> - 2018-06-26 10:29 -0500

csiph-web