Difference: JavaNotes (16 vs. 17)

Revision 1710 Nov 2003 - TobyCabot

Line: 1 to 1
 
META TOPICPARENT name="ProgrammingTips"
(back to ProgrammingTips)
Line: 83 to 83
  In summary, an array is the correct data structure to use where you have a known number of objects all of the same type.
Added:
>
>

Float sucks

Binary arithmetic (e.g. Java float) doesn't cut it when applied to money - it's not accurate on the right side of the decimal point. Java seems to have the answer in java.math.BigDecimal but from what I've seen on the web it's not a very good implementation.

IBM has proposed a replacement of the BigDecimal class, the website is at http://www2.hursley.ibm.com/decimalj/. The site does a great job of explaining why decimal arithmetic is better than binary and also has many interesting links. They also have an implementation available but it's under a very restrictive license, you can only use it for 90 days and then you must destroy it - there's no way to buy it, either.

The IBM page points to a commercial implementation of a BigDecimal class at http://users.belgacombusiness.net/arci/math/. It's not very expensive - 500 Euro (which is closer to $500 than those common-market pinkos would hope!). It claims to be fast and have good formatting features.

There was another implementation but it seems to have fallen off the net. Google had cached entries for a package called TCE/Java at http://www.voicenet.com/~hsk0/tce/ but it seems to have fallen off the net. The guy that wrote it is Howard Kapustein, maybe he'll show up again.

 

Misc Notes

IBM's JVM 1.4.1 for GNU/Linux doesn't seem to recognize old-style timezone names. My /etc/localtime was a link to /usr/share/zoneinfo/US/Eastern and the JVM would never use daylight savings - it was always GMT+5. When I changed the link to /usr/share/zoneinfo/America/New_York it worked fine. See http://www.mainframeforum.com/t590240.html which seems to be relevant despite being a mainframe forum.

public class date { public static void main(String[] argv) throws java.io.IOException {System.out.println(new java.util.Date()); }}

Changed:
<
<
-- TobyCabot - 28 Dec 2001 - 24 Jun 2003
>
>
-- TobyCabot - 28 Dec 2001 - 10 Nov 2003
View topic | History: r36 < r35 < r34 < r33 | More topic actions...
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding The Caboteria? Send feedback