News for hackers. Stuff that matters.
Re:Unexpected Ways in which Bitcoin Dodged Some Cryptographi... by ploureiro on Thursday October 31, 2013 @05:00AM (#6645815)
"my own BitcoinJS fork (which also adds other improvements) does use plain numbers to store the number of satoshis."

Why wouldn't I feel tempted to use his fork?..

Re:Unexpected Ways in which Bitcoin Dodged Some Cryptographi... by enimodas on Thursday October 31, 2013 @05:14AM (#6645846)
my thoughts exactly. For those who don't know, never ever use floats for things like money. Try in windows calculator for example sqrt(4) - 2 and see why.

Strangely enough he talks about floating point rounding errors in one of the next paragraphs?

Re:Unexpected Ways in which Bitcoin Dodged Some Cryptographi... by vbuterin on Thursday October 31, 2013 @05:54AM (#6645950)
> For those who don't know, never ever use floats for things like money.

This is normally a very good rule to follow. The reason is that floating point is binary, whereas cash is decimal, so even an innocent number like 0.4 has no exact representation in binary (it's actually an infinite tail: 0.011001100110011...).

Here, however, I'm using floats NOT to store decimals; every single value that I store is an integer. There is absolutely no danger in using floating point numbers to store relatively small integers like 1253251126; the issue only arises in the context of very large numbers (specifically, those above 2^53) and decimals. If anyone can come up with a remotely realistic series of integer manipulations that will cause an inaccuracy in Javascript where all values always stay below 2^50.9, I will certainly abandon my choice of moving to integers at once; otherwise, I see no problem.

Re:Unexpected Ways in which Bitcoin Dodged Some Cryptographi... by shalmanese on Monday November 04, 2013 @10:36PM (#6673077)
Still seems risky to me. There are some numeric calculations where input and output values are small but intermediate representations might be many times larger. It's not certain that all the people working after you are going to be aware of the assumptions intrinsic in your code.
Re:Unexpected Ways in which Bitcoin Dodged Some Cryptographi... by Luc on Thursday October 31, 2013 @06:00AM (#6645961)
It's explained rather well in the article, over several paragraphs, why it's okay to use floating point in this case.

The first thing we did in the programming class at university was to learn how the IEEE floating point standard works...

Re:Unexpected Ways in which Bitcoin Dodged Some Cryptographi... by simias on Thursday October 31, 2013 @06:51AM (#6646086)
That sounds like a very dull programming class...
Re:Unexpected Ways in which Bitcoin Dodged Some Cryptographi... by Luc on Thursday October 31, 2013 @07:08AM (#6646128)
Yeah, motivating students was not part of their job description. It was all rather backward, and I expect many professors saw it as a way of weeding out the unworthy (here's a bunch of very abstract math, study this for months but we won't tell you why it's important to know as a physicist).
Re:Unexpected Ways in which Bitcoin Dodged Some Cryptographi... by eru on Thursday October 31, 2013 @08:09AM (#6646314)
Floating point arithmetic is some of the least abstract math. (That doesn't make it more interesting without the right background and mindset, though.)
Re:Unexpected Ways in which Bitcoin Dodged Some Cryptographi... by Luc on Thursday October 31, 2013 @08:30AM (#6646374)
True, I wasn't clear I guess, but I was trying to say that not explaining WHY we had to learn something was a general feature of my university education, e.g. group theory in the case of math. They just put us physics students with the math students and we were expected to be motivated by the pure fun of learning math. If I had known how much group theory gets used in physics, I'd have put in more effort.

Same thing with the IEEE standard, it's not hard, but it was presented in a dull way, all theory.

Re:Unexpected Ways in which Bitcoin Dodged Some Cryptographi... by eru on Thursday October 31, 2013 @11:47AM (#6647475)
Yes, presentation (and motivating the design) is key here. Just learning the IEEE floating point standard in itself is dull. Learning about the standard's history and design trade-offs might enliven the lesson somewhat. Same with group theory.