tag:blogger.com,1999:blog-3244621.post110714605565533246..comments2022-03-31T07:56:33.638+07:00Comments on a developer's perspective: double vs. BigDecimalEric Pramonohttp://www.blogger.com/profile/11743478514291412345noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-3244621.post-59754409704445407622011-07-05T09:38:21.995+07:002011-07-05T09:38:21.995+07:00Its awesome , thanks againIts awesome , thanks againAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-3244621.post-16547653007790216082011-01-17T17:52:20.055+07:002011-01-17T17:52:20.055+07:00Be aware that locale may influence the example giv...Be aware that locale may influence the example given. In certain countries such as i.e. Sweden and Norway, the fraction indicator is a , (comma) which will make the BigDecimal constructor throw a NumberFormatException.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3244621.post-45280702828148379492010-12-11T04:07:55.025+07:002010-12-11T04:07:55.025+07:00pak, emang bisa ya infinite loop waktu compare flo...pak, emang bisa ya infinite loop waktu compare float/double ?Ronnynoreply@blogger.comtag:blogger.com,1999:blog-3244621.post-6071410521405273802010-09-23T21:19:49.932+07:002010-09-23T21:19:49.932+07:00Java can represent some floating point numbers pre...Java <i>can</i> represent some floating point numbers precisely, namely those that have an exact binary fraction part, for example, 0.5 or 99.375MikeWnoreply@blogger.comtag:blogger.com,1999:blog-3244621.post-90210335338072432042010-08-18T17:31:35.125+07:002010-08-18T17:31:35.125+07:00I think that the example provided could be improve...I think that the example provided could be improved by getting rid of duplicates (formatting and instantiating) in add() methods ..method like BigDecimal convert(double value) would add value in my view<br /><br />thxOleghttps://www.blogger.com/profile/07030980827869763554noreply@blogger.comtag:blogger.com,1999:blog-3244621.post-85042026043467339152009-08-14T13:37:13.719+07:002009-08-14T13:37:13.719+07:00why java is having problem in representing floatin...why java is having problem in representing floating numbers, when executed same program in C it gives exact answer (0.1+0.1+0.1...=1.0)? can someone throw light on insight of java's way of representing numbers?<br />why it works in C?Yogeshhttps://www.blogger.com/profile/09244373728649168114noreply@blogger.comtag:blogger.com,1999:blog-3244621.post-22243838389756073762009-01-14T00:51:00.000+07:002009-01-14T00:51:00.000+07:00I appreciate Scotts comments, but it is impractica...I appreciate Scotts comments, but it is impractical when you target a third party to use your code. I would definitely go the authors way as I have already implemented this long ago and it met the expectations. Thanks again.Guru Kaipahttps://www.blogger.com/profile/03827668740622111220noreply@blogger.comtag:blogger.com,1999:blog-3244621.post-23707055177038816432008-12-04T03:47:00.000+07:002008-12-04T03:47:00.000+07:00BigDecimal Vs Doublehttp://java-j2ee-interview-que...BigDecimal Vs Double<BR/><BR/>http://java-j2ee-interview-questions2.blogspot.com/2008/12/bigdecimal-vs-double.htmlAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-3244621.post-71660789730892435312008-12-03T03:37:00.000+07:002008-12-03T03:37:00.000+07:00Nice, but there is a flaw in your add() method. If...Nice, but there is a flaw in your add() method. If a and b are both null, it will return zero; if a is null but b is not null, it will return b; however, if a is not null but b is null, it will throw a null pointer exception.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3244621.post-75223337571997076782008-11-28T23:17:00.000+07:002008-11-28T23:17:00.000+07:00for a simple program like to reversea number like ...for a simple program like to reverse<BR/>a number like 789.123456 to 654321.987 the code i built was<BR/>import java.io.DataInputStream;<BR/>class Reverse<BR/>{<BR/> public static void main(String args[])<BR/> {<BR/> double a=0.0,b=0.0;<BR/> int c=0,d=0,e=0;<BR/> DataInputStream in = new DataInputStream(System.in);<BR/> System.out.println("Enter a number");<BR/> try<BR/> {<BR/> a = Unknownhttps://www.blogger.com/profile/15469385149684063806noreply@blogger.comtag:blogger.com,1999:blog-3244621.post-26114268179920299532008-11-20T18:05:00.000+07:002008-11-20T18:05:00.000+07:00Hi,Do you have an example for your comparaison "in...Hi,<BR/>Do you have an example for your comparaison "infinite loop" with "=="<BR/>Thanks for your postAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-3244621.post-79595373302898204482008-11-06T03:37:00.000+07:002008-11-06T03:37:00.000+07:00I disagree with the statement "This is because Jav...I disagree with the statement "This is because Java cannot represent floating-point precisely", as if this were a Java problem.<BR/>All programming languages have the same problem that "0.1" cannot be represented exactly by a computer. Float (32 bit precision) is the least precise, while BigDecimal (arbitrary precision) is the most precise.<BR/><BR/>As a programmer, you should periodically ask scotthttps://www.blogger.com/profile/18242456619938514947noreply@blogger.comtag:blogger.com,1999:blog-3244621.post-10081184272131363322008-11-06T01:43:00.000+07:002008-11-06T01:43:00.000+07:00The statement "Java cannot represent floating-poin...The statement "Java cannot represent floating-point precisely." Is misleading. As if it were somehow Java's fault or a bug.<BR/>Java is doing what every other language does when operating on 32 or 64 bit floats (float and double).<BR/>The problem is that it's impossible to represent "1.0" exactly on a computer. (BigDecimal isn't exact either by the way).<BR/><BR/>Each programmer should determine scotthttps://www.blogger.com/profile/18242456619938514947noreply@blogger.comtag:blogger.com,1999:blog-3244621.post-46089277453650734212008-03-11T05:27:00.000+07:002008-03-11T05:27:00.000+07:00Amazing blog. Amazing news. What's the difference ...Amazing blog. Amazing news. What's the difference between comparing two doubles and their bit representation? It would be amazing if these two operations were not exactly the same.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3244621.post-45632707270910380942007-11-13T03:50:00.000+07:002007-11-13T03:50:00.000+07:00Look at that thread for an issue with BigDecimal w...Look at that thread for an issue with BigDecimal when using divide.<BR/><BR/><BR/>http://forum.java.sun.com/thread.jspa?threadID=682611&messageID=3977174RPhttps://www.blogger.com/profile/02341741878603138671noreply@blogger.comtag:blogger.com,1999:blog-3244621.post-15012335687319035302007-05-31T22:26:00.000+07:002007-05-31T22:26:00.000+07:00A very informative Blog and good explanation provi...A very informative Blog and good explanation provided with example code. It was really helpful to clear my concepts :).Unknownhttps://www.blogger.com/profile/10616571836073670656noreply@blogger.comtag:blogger.com,1999:blog-3244621.post-28328090773379900252007-05-13T04:02:00.000+07:002007-05-13T04:02:00.000+07:00thanks for your great insight bless youthanks for your great insight bless youUnknownhttps://www.blogger.com/profile/14965120804280091238noreply@blogger.comtag:blogger.com,1999:blog-3244621.post-1167823949139938552007-01-03T18:32:00.000+07:002007-01-03T18:32:00.000+07:00I was asked to convery a program from double to Bi...I was asked to convery a program from double to Bigdecimal usage through out. This blog really helped clear up reasons for it. ThanksAnonymousnoreply@blogger.com