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 13:44:42 -0500 Organization: Agency News - Dunedin, New Zealand Message-ID: <5B329ADB.1166.ucljprogr@castlerockbbs.com> References: <5B329ADB.1165.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: bursejan X-Comment-To: bursejan X-FTN-MSGID: 1:261/38.0 b9accfec X-Gateway: castlerockbbs.com [Synchronet 3.17a-Linux NewsLink 1.108] X-FTN-AREA: COMP.LANG.JAVA.PROGRAMMER X-FTN-REPLY: 1:261/38.0 86a26328 X-FTN-Kludge: CHARSET: LATIN-1 In-Reply-To: <5B329ADB.1165.ucljprogr@castlerockbbs.com> Xref: csiph.com comp.lang.java.programmer:38427 To: bursejan From: "bursejan" To: bursejan From: bursejan@gmail.com You can try the same Java code on a Android device. The result will be (Android 8.0.0): Math.pow(10,22)=1.0E22 Math.pow(10,23)=9.999999999999999E22 Math.pow(10,24)=1.0E24 I used AIDE-IDE to compile and run the Java directly on the device. But the above is not the same test case as in my initial post. My initial post also tests BigInteger.pow() and BigInteger.doubleValue(). Am Sonntag, 24. Juni 2018 22:35:50 UTC+2 schrieb burs...@gmail.com: > 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.. > > Am Sonntag, 24. Juni 2018 22:31:44 UTC+2 schrieb burs...@gmail.com: > > You cannot use the strictfp keyword in front > > of Math.pow(). Thats only for the basic operations. > > > > Math.pow() itself is implemented in JDK 1.8 as follows: > > > > public static double pow(double a, double b) { > > return StrictMath.pow(a, b); // default impl. delegates to StrictMath > > } > > > > Am Sonntag, 24. Juni 2018 21:21:57 UTC+2 schrieb Arne VajhÄ,j: > > > On 6/24/2018 2:41 PM, j4n bur53 wrote: > > > > Running a simple test. > > > > ** is Math.pow(), > > > > ^ is BigInteger.pow() and then BigInteger.doubleValue(). > > > > > > > > On Java: > > > > > > > > â ?- between(15,30,N), X is 10**N-10^N, write(N-X), nl, fail; true. > > > > â 15-0.0 > > > > > > > â 23-1.6777216E7 > > > > > > > â 29-0.0 > > > > â 30-0.0 > > > > > > > > On Adroid: > > > > > > > > â ?- between(15,30,N), X is 10**N-10^N, write(N-X), nl, fail; true. > > > > â 15-0.0 > > > > > > > â 23-0.0 > > > > > > > â 29-1.7592186044416E13 > > > > â 30-0.0 > > > > > > > > Has Android different floats? > > > > Tested jdk1.8.0_152 against Android 8.0.0 > > > > > > ARM supposedly use standard IEEE 754 FP. > > > > > > But I wonder if usage of strictfp would change your results. > > > > > > Arne -+- BBBS/Li6 v4.10 Toy-3 + Origin: Prism bbs (1:261/38) --- BBBS/Li6 v4.10 Toy-3 * Origin: Prism bbs (1:261/38)