• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Bad precision Math.log10? [solved: user error]

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having trouble getting good results with quite simple calculations with Math.log10. For instance, I get Math.log10(16)/Math.log10(2)=3.906890595..., but I should get 4.0... Why is this? I'm not doing anything fancy at all, just

to do a base conversion...
I'm using JDK1.6.0_05-b13 on SunOS(sparc SUNW,ultra-4)
[ July 03, 2008: Message edited by: Carl Pettersson ]
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried this just now on Windows XP, with Sun Java 1.6.0 update 6:

The output is: 4.0

You probably know that data types such as double are not infinitely precise. Do you yet 3.90... if you run that exact code? That would be strange. You could try searching the Sun bug database if there's a known issue with regard to this on SunOS.

Do you have another computer (with maybe a different OS) on which you can test your code?
 
Carl Pettersson
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is never too late to be stupid... I've been misreading my output for a few hours straight now About time I call it a day I think. Sorry for any wasted effort...
 
Why should I lose weight? They make bigger overalls. And they sure don't make overalls for tiny ads:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic