Skip to main content

Just two kind to Quantity in SE-impl

  • From: Otávio Gonçalves de Santana < >
  • To:
  • Subject: Just two kind to Quantity in SE-impl
  • Date: Sun, 14 Sep 2014 08:01:19 -0300

In Java SE world, there is a warning about calculates with floating
numbers, following some approach and advices in books and blogs, was
included the most famous book about Java in the world, the Java Effective
<http://www.amazon.com/Effective-Java-Edition-Joshua-Bloch/dp/0321356683>.
When you want calculate something that you really need high precision, such
a money, you may use two ways:


   - using BigDecimal
   - using integer values

It will facilitate the maintenance code, considering we have just two
kinds, and get performance to do parse and less the error with parser, when
we are using stream:


List<Quantity<Length>> lenghts = getMeasures();

Quantity<Length> quantity = lenghts.stream().map(m ->
m.to(US.FOOT)).reduce((m1,
m2) -> m1.add(m2)).get();

System.out.println(quantity);


In money we are doing following this concern:

https://github.com/JavaMoney/jsr354-ri/blob/master/src/main/java/org/javamoney/moneta/FastMoney.java

https://github.com/JavaMoney/jsr354-ri/blob/master/src/main/java/org/javamoney/moneta/Money.java

I believe this case will be the same since both deal with important
floating calculations

obs: I am just talking about SE implementations


-- 
Otávio Gonçalves de Santana

blog:     http://otaviosantana.blogspot.com.br/
twitter: http://twitter.com/otaviojava
site:     *http://about.me/otaviojava ;<http://about.me/otaviojava>*
55 (11) 98255-3513


Just two kind to Quantity in SE-impl

Otávio Gonçalves de Santana 09/14/2014

Re: Just two kind to Quantity in SE-impl

Werner Keil 09/14/2014

Re: Just two kind to Quantity in SE-impl

Otávio Gonçalves de Santana 09/14/2014

Re: Just two kind to Quantity in SE-impl

Werner Keil 09/14/2014

Re: Just two kind to Quantity in SE-impl

Werner Keil 09/14/2014

Re: Just two kind to Quantity in SE-impl

Otávio Gonçalves de Santana 09/15/2014

Re: Just two kind to Quantity in SE-impl

Otávio Gonçalves de Santana 09/15/2014

Re: Just two kind to Quantity in SE-impl

Werner Keil 09/15/2014

Re: Just two kind to Quantity in SE-impl

Otávio Gonçalves de Santana 09/15/2014

Re: Just two kind to Quantity in SE-impl

Werner Keil 09/16/2014

Re: Just two kind to Quantity in SE-impl

Martin Desruisseaux 09/21/2014
 
 
Close
loading
Please Confirm
Close