"A discerning developer just declared that when dealing with dollars, doubles are a dodgy deal".
Don't use float or double types to handle money in your programs. Use BigDecimal instead, or something equivalent in non-JVM languages.
The 'float' type has only 6 or 7 digits of accuracy, although it may appear to have more precision. Money values over $150K will start losing precision at about a cent at a time just from raw display, and there may be larger rounding errors when doing computations such as sales tax. The float type has a "mantissa" (the numerical part aside from the exponent) of 24 bits--this is where you get 24 bits of accuracy; 2^24 = 16777216, and if this is a monetary value then you are losing accuracy after you get over $167,772.16 -- if the only thing you are doing is displaying numbers. You may have fewer significant digits when you start doing calculations.
Using the 'double' type is less dangerous, but still prone to errors especially when doing mathematical operations on money. Double values have 14 to 15 digits of accuracy, but during financial calculations such as sales tax or interest rates, you might be losing pennies that eventually add up to millions.
This emphasizes the importance of testing not merely big numbers, but numbers with many significant digits.
Here's a handy guide to the problem of using floats, in a variety of contexts.
BigDecimal, on the other hand, represents decimal values as integers and an exponent. They can store arbitrary-precision values, as well as compute them accurately while giving you explicit control over rounding.
Wednesday, January 8, 2014
Tuesday, October 29, 2013
Understanding css style rule precedence
CSS style rules have precedence depending on what kind of
selectors you have. For example, a selector on an id has higher
precedence than one just on element type. But it’s more complicated than
that.
Here’s a quick read that I found helpful:
(re-post) "The Two Things"
I'm re-posting this article I learned about from The Dev Show podcast:
The Two Things about Computer Programming
The Two Things about Computer Programming
Thursday, October 24, 2013
Set goals to work on both strengths and weaknesses
In a one-on-one with my manager some weeks back, it was time to set some goals. An idea came to mind, based on some religious literature I'd been reading. I decided to choose two goals to work on: one goal would focus on a weakness, and one goal on a strength (on increasing a talent I already had).
I thought I was a fairly good communicator. I felt that was a strength--I had been complimented on my communication skills by a previous manager, and I felt fairly confident about my abilities--especially my written abilities. Once I started working on this with my manager, I realized I had a lot to learn. As I included him in more of my communication and got some constructive feedback, he helped me see additional ways to improve. I attended a couple training classes offered by my workplace on emotional awareness and other topics. I talked to another manager about a couple communication techniques. I read a couple blog posts I could find via Google. In the end, it turned out I had a lot to learn, and I was left feeling like I hadn't learned all I could.
This was an important lesson for me. There are plenty of weaknesses any of us can work on. But in all my efforts to overcome weaknesses, it can be easy to forget to take time to build on my talents, my strengths. Incidentally, by looking to improve on my strengths, I realized I could learn a lot from those around me, and it was appropriately humbling--humbling in a good way.
God is good to me.
I thought I was a fairly good communicator. I felt that was a strength--I had been complimented on my communication skills by a previous manager, and I felt fairly confident about my abilities--especially my written abilities. Once I started working on this with my manager, I realized I had a lot to learn. As I included him in more of my communication and got some constructive feedback, he helped me see additional ways to improve. I attended a couple training classes offered by my workplace on emotional awareness and other topics. I talked to another manager about a couple communication techniques. I read a couple blog posts I could find via Google. In the end, it turned out I had a lot to learn, and I was left feeling like I hadn't learned all I could.
This was an important lesson for me. There are plenty of weaknesses any of us can work on. But in all my efforts to overcome weaknesses, it can be easy to forget to take time to build on my talents, my strengths. Incidentally, by looking to improve on my strengths, I realized I could learn a lot from those around me, and it was appropriately humbling--humbling in a good way.
God is good to me.
Wednesday, October 16, 2013
jQuery tutorial
Even if you think you know jQuery, this tutorial is likely to teach you some tricks.
http://net.tutsplus.com/sessions/jquery-succinctly/
http://net.tutsplus.com/sessions/jquery-succinctly/
Monday, July 15, 2013
Resources for diagnosing and fixing heisenbugs
http://www.javacodegeeks.com/2012/08/fixing-bugs-that-cant-be-reproduced.html
http://stackoverflow.com/questions/1268373/how-do-you-fix-a-bug-you-cant-replicate
http://stackoverflow.com/questions/352906/how-do-you-approach-intermittent-bugs
http://www.satisfice.com/blog/archives/34 (James Bach's blog for software testers)
http://www.kohl.ca/2005/tracking-intermittent-bugs/
http://stackoverflow.com/questions/1050552/any-good-strategies-for-dealing-with-not-reproducible-bugs
http://stackoverflow.com/questions/1268373/how-do-you-fix-a-bug-you-cant-replicate
http://stackoverflow.com/questions/352906/how-do-you-approach-intermittent-bugs
http://www.satisfice.com/blog/archives/34 (James Bach's blog for software testers)
http://www.kohl.ca/2005/tracking-intermittent-bugs/
http://stackoverflow.com/questions/1050552/any-good-strategies-for-dealing-with-not-reproducible-bugs
Wednesday, June 26, 2013
Alternative Kanban (think outside the box) (re-post)
This post helps one to realize if their idea of kanban is stuck to something too specific. And it gives new ideas for creating a new kind of kanban board.
http://brodzinski.com/2011/11/alternative-kanban-board.html
http://brodzinski.com/2011/11/alternative-kanban-board.html
Subscribe to:
Posts (Atom)