Path: csiph.com!news.bbs.nz!.POSTED.184-155-113-241.cpe.cableone.net!not-for-mail From: "bursejan" Newsgroups: comp.lang.java.programmer Subject: Re: Has Android different floats? Date: Sun, 24 Jun 2018 16:08:38 -0500 Organization: Agency News - Dunedin, New Zealand Message-ID: <5B329ADB.1168.ucljprogr@castlerockbbs.com> References: <5B329ADB.1167.ucljprogr@castlerockbbs.com> Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit Injection-Info: news.bbs.nz; posting-host="OzrHixpCILyhgWpD0JEChpw8GfzwXVr5j8UB2bSv2xw"; logging-data="16453"; mail-complaints-to="abuse@news.bbs.nz" To: Eric Sosman X-Comment-To: Eric Sosman X-FTN-MSGID: 1:261/38.0 d460b62c X-Gateway: castlerockbbs.com [Synchronet 3.17a-Linux NewsLink 1.108] X-FTN-REPLY: 1:261/38.0 ae2a014b X-FTN-AREA: COMP.LANG.JAVA.PROGRAMMER X-FTN-Kludge: CHARSET: LATIN-1 In-Reply-To: <5B329ADB.1167.ucljprogr@castlerockbbs.com> Xref: csiph.com comp.lang.java.programmer:38429 To: Eric Sosman From: "bursejan" To: Eric Sosman From: bursejan@gmail.com Yes, this seems to be the explanation, on the windows platform, Math.pow() seems to get replaced by something else than StrictMath.pow(). With StrictMath.pow() (JDK 1.8, Windows): Math.pow(10,22)=1.0E22 Math.pow(10,23)=9.999999999999999E22 Math.pow(10,24)=1.0E24 With Math.pow() (JDK 1.8, Windows): Math.pow(10,22)=1.0E22 Math.pow(10,23)=1.0000000000000001E23 Math.pow(10,24)=1.0E24 What is Math.pow() doing on Windows, some Wintel nonsense? Am Sonntag, 24. Juni 2018 23:29:11 UTC+2 schrieb Eric Sosman: > 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) --- BBBS/Li6 v4.10 Toy-3 * Origin: Prism bbs (1:261/38)