Difference between string and double

Why would double conversion in the following yields different results?

System.err.println(new BigDecimal("42.21").subtract(new BigDecimal("12.12")));

30.09

System.err.println(new BigDecimal(42.21).subtract(new BigDecimal(12.12)));

30.0900000000000016342482922482304275035858154296875

Can any expert help me figure out the intention of java programmers to do this way?

[404 byte] By [siva@suna] at [2007-11-27 2:12:58]
# 1
this might have something to do with issues surrounding floating points, atleast that what it smells like.
mkoryaka at 2007-7-12 2:07:54 > top of Java-index,Java Essentials,Java Programming...
# 2
Rounding errors. http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
CaptainMorgan08a at 2007-7-12 2:07:54 > top of Java-index,Java Essentials,Java Programming...
# 3
Read this: [url= http://java.sun.com/javase/6/docs/api/java/math/BigDecimal.html#BigDecimal(double)]BigDecimal(double)[/url]
DrLaszloJamfa at 2007-7-12 2:07:54 > top of Java-index,Java Essentials,Java Programming...
# 4
> this might have something to do with issues> surrounding floating points, atleast that what it> smells like.and thats one reason that in some brokerage companies deal and trading amounts are stored in DB as strings and not doubles
kilyasa at 2007-7-12 2:07:54 > top of Java-index,Java Essentials,Java Programming...