Path: csiph.com!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: [OT] Re: missing import java.lang.Comparable Date: Mon, 18 Jul 2016 19:56:48 -0400 Organization: Aioe.org NNTP Server Lines: 41 Message-ID: References: <638a1d64-f125-4456-a20b-4dbf45f49da2@googlegroups.com> <60a5ccde-2657-48d6-b3dd-04ec1a0973ab@googlegroups.com> <3pdqobtjvvggbu0h92ajhacqseto47sjns@4ax.com> NNTP-Posting-Host: 7SK6yTFfqwlIPNBLl3l7Qg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:34966 On 7/18/2016 4:08 PM, Gene Wirchenko wrote: > On Fri, 15 Jul 2016 22:09:34 -0400, Arne Vajhøj > wrote: >> On 7/15/2016 6:49 PM, Gene Wirchenko wrote: >>> On Fri, 15 Jul 2016 16:36:38 -0400, Arne Vajhøj >>> wrote: >>>> JavaScript is a great language for many things, but I would not >>>> pick it for financial calculations. >>> >>> "financial calculations" is rather vague. >> >> True. >> >>> Adding up items on an >>> invoice is financial calculations. >> >> Yes. And one of the cases where floating point should not be used. > > But it can be used safely with certain limitations. And since > JavaScript only has one numeric type, one has to. You could do that add server side a suitable type. Like BigDecimal in Java. Or similar in .NET. You could also use COBOL, but having COBOL return data directly to browser would be unusual. Or you could write something doing BCD math in JS. Alternatively you would need to invent a solid framework on how to detect reaching the mentioned limitations and handle that situation. That will likely be much more work. Deploying code that works in all simple cases now, but have a builtin problem that may cause it to break later is definitely not a good solution. Arne