Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Has Android different floats? Date: Sun, 24 Jun 2018 17:28:58 -0400 Organization: A noiseless patient Spider Lines: 37 Message-ID: References: <90082b6a-1547-4825-83f5-34f0762daad4@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 24 Jun 2018 21:29:00 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="0b9b5c021bb5c2ed7fe9e82cce2d4cd0"; logging-data="22409"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/xYyhxVDGDukF+nJmRHiEb" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 Cancel-Lock: sha1:Yg4KoY3G/n9Ddw6t/rFtQgizrSQ= In-Reply-To: <90082b6a-1547-4825-83f5-34f0762daad4@googlegroups.com> Content-Language: en-US Xref: csiph.com comp.lang.java.programmer:38405 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.