> If variables are stored in IEEE format and a different format is used for intermediate calculations, then there is converting going on and that takes time.
No. The different format for intermediate calculations is what the CPU uses internally (usually 80 bit, using a 64 bit mantissa to reuse 64 bit int circuits), so converting to and from that happens anyway and is built into the hardware. But if intermediate results have to be converted to IEEE 754 format, *that* takes extra work.
Perhaps the best solution is to stop thinking about a relative error margin between real numbers and instead consider the error margin as a maximum number of discrete ulp steps - I've added that suggestion to the page.
In case you weren't just being funny, that == is correct, as it's meant to prevent NaN or Infinity results from the division, which can only happen with the actual "zero" values.
Sure it can be: by starting with simple explanations fit for novices (who usually aren't actually doing serious numerical math and simply wonder how come 0.1 + 02 != 0.3) and getting into more details progressively.
And I mention the alternatives to floating-point formats and when to use what.
Actually, it will yield the correct result because (nonzero)/0 = Infinity. But it will return the wrong result for a smaller than epsilon. Will correct that.
I'm very sorry for whatever horrible things happened to you that makes you read that into my words. They were meant as an acceptance of the suggestion that a section about interval arithmetic would be a good addition to the site and an invitation to contribute.
You've never done any scientific computing, it seems. While it's a very broad term, and floats certainly not the best tool for *all* computing done by science, anyone with even the most basic understanding knows that IEEE 754 floats *are* the best tool most of the time and exactly the result of deciding how much accuracy you need and implementing that with as many bytes of data as it takes. Hardly anything in the natural sciences needs more accuracy than a 64 bit float can provide.
I would suggest you heed your own advice: do some research before mouthing off. Yes, there's a lot of stuff about FP math. But there didn't seem to be anything that is both novice-friendly and comprehensive.
Well, I'll do it when I get around to it. Doing it as a wiki would mean that I'd have to deal with vandalism and spam, and it's really intended more as small self-contained site than a community thing.
Actually, I tried to make it very clear in several places that base 10 has just the same problems. I am open to any suggestions for improvement, though.
The non-trivial problems with floating-point really only turn up in the kind of calculations where *any* format would have the same or worse problems (most scientific computing simply *cannot* be done in integers, as they overflow too easily).
Floating-point is an excellent tool, you just have to know what it can and cannot do.
These days, not everyone who writes programs has some sort of formal CS education. And those who do may have forgotten about it by the time they run into this kind of problem.
I think the main problem of most MMORPGs, which manifests in gold farming, is that in those games, how good you are is determined by stats and equipment, and both can be acquired only by spending a lot of time in game (or having other people do it for you), and that it takes high stats and good equipment to be able to play the more advanced parts of the game, which to most people is highly desirable. You might be able to get there just playing regularly and casually, but if you want to get there quickly, you have to grind.
For an example of an MMORPG that has mostly eliminated these problems and level grind, see http://www.puzzlepirates.com/ Basically, skills are based on Tetris-like puzzle games, and your stats represent not how often you have played the puzzles, but how WELL you have played them. Having someone else level up your character is completely pointless because if you can't play the puzzles as well, your stat will drop quite quickly. And stats gain you little except bragging rights, they don't make you more powerful. So grinding for stats is not possible. Grinding for money is possible but not required if you have top skills instead. Also, almost everything you can buy for money does not make you more powerfuly either, it's just shiny stuff i.e. again bragging rights.
Also, the game has completely eliminated RTM trading by introducing a second currency (Doubloons) that is used as micro-payment to unlock certain aspects of the game. This replaces the monthly fee, but at the same time, Doubloons can be traded in an open in-game market for the regular in-game currency, with prices adjusting to supply and demand. If you don't have the skills and don't want to grind for money, you can buy lots of Doubloons directly from the game company and exchange them for in-game money on the market. Voila, an official alternative for RTM that does not introduce inflation (due to the unfixed market price for Doubloons)
Isn't it a moral imperative in a capitalistic society for the smart to profit off the stupid?
No. Capitalism concerns itself with economical imperatives, not morals. What you're thinking about is Social Darwinism. The two are not the same, despite the attempts of many to blur the distinction.
Yeah, the best possible world is one where everyone is armed and knows everyone else to be armed so that anyone having a bad day or misjudging a situation turns into a major bloodbath.
Which had a lot of history to recommend it -- pretty much every time in history Germany was unified a big war broke out.
That's about as idiotic a statement as is possible to make. Germany was unified for the first time in 1870, AFTER Prussia won a war against France and thereby gained enough clout to make it happen. It stayed unified for 75 years, through the two world wars. It was unified the second time in 1990, with no war to follow.
> If variables are stored in IEEE format and a different format is used for intermediate calculations, then there is converting going on and that takes time.
No. The different format for intermediate calculations is what the CPU uses internally (usually 80 bit, using a 64 bit mantissa to reuse 64 bit int circuits), so converting to and from that happens anyway and is built into the hardware. But if intermediate results have to be converted to IEEE 754 format, *that* takes extra work.
Still returns false for a=ulp and b=-ulp, I think
Perhaps the best solution is to stop thinking about a relative error margin between real numbers and instead consider the error margin as a maximum number of discrete ulp steps - I've added that suggestion to the page.
> 1/3 isn't irrational, and can be written with recurring digits
So where does that contradict my statement?
> How about e? We use it for the base in Natural Logarithms, where it would be 10.
I don't think anyone uses non-integer bases to write down fractions in positional notation.
In case you weren't just being funny, that == is correct, as it's meant to prevent NaN or Infinity results from the division, which can only happen with the actual "zero" values.
I have changed the comparison page, hopefully the algorithm is correct now.
Do you really believe that what someone wondering why 0.1 + 0.2 != 0.3 needs is a format with more than 52 bits of precision?
Fails on a=epsilon/2 and b=0
Sure it can be: by starting with simple explanations fit for novices (who usually aren't actually doing serious numerical math and simply wonder how come 0.1 + 02 != 0.3) and getting into more details progressively.
And I mention the alternatives to floating-point formats and when to use what.
On second glance, your code seems to be wrong too, because it uses epsilon as an *absolute* error measure.
Actually, it will yield the correct result because (nonzero)/0 = Infinity. But it will return the wrong result for a smaller than epsilon. Will correct that.
I'm very sorry for whatever horrible things happened to you that makes you read that into my words. They were meant as an acceptance of the suggestion that a section about interval arithmetic would be a good addition to the site and an invitation to contribute.
You've never done any scientific computing, it seems. While it's a very broad term, and floats certainly not the best tool for *all* computing done by science, anyone with even the most basic understanding knows that IEEE 754 floats *are* the best tool most of the time and exactly the result of deciding how much accuracy you need and implementing that with as many bytes of data as it takes. Hardly anything in the natural sciences needs more accuracy than a 64 bit float can provide.
I would suggest you heed your own advice: do some research before mouthing off. Yes, there's a lot of stuff about FP math. But there didn't seem to be anything that is both novice-friendly and comprehensive.
Well, I'll do it when I get around to it. Doing it as a wiki would mean that I'd have to deal with vandalism and spam, and it's really intended more as small self-contained site than a community thing.
Actually, I tried to make it very clear in several places that base 10 has just the same problems. I am open to any suggestions for improvement, though.
The non-trivial problems with floating-point really only turn up in the kind of calculations where *any* format would have the same or worse problems (most scientific computing simply *cannot* be done in integers, as they overflow too easily).
Floating-point is an excellent tool, you just have to know what it can and cannot do.
These days, not everyone who writes programs has some sort of formal CS education. And those who do may have forgotten about it by the time they run into this kind of problem.
Why don't you write it up yourself and give me a github pull request? :)
True, but irrational numbers are those that cannot be written down exactly in *any* base - not even if you use recurring digits.
Done :)
> If I walked into a bar in Europe and they were unable to serve me a pint, with no further explanation on my part, I would leave.
Then don't bother entering any bars in mainland Europe in the first place.
I think the main problem of most MMORPGs, which manifests in gold farming, is that in those games, how good you are is determined by stats and equipment, and both can be acquired only by spending a lot of time in game (or having other people do it for you), and that it takes high stats and good equipment to be able to play the more advanced parts of the game, which to most people is highly desirable. You might be able to get there just playing regularly and casually, but if you want to get there quickly, you have to grind.
For an example of an MMORPG that has mostly eliminated these problems and level grind, see http://www.puzzlepirates.com/
Basically, skills are based on Tetris-like puzzle games, and your stats represent not how often you have played the puzzles, but how WELL you have played them. Having someone else level up your character is completely pointless because if you can't play the puzzles as well, your stat will drop quite quickly. And stats gain you little except bragging rights, they don't make you more powerful. So grinding for stats is not possible. Grinding for money is possible but not required if you have top skills instead. Also, almost everything you can buy for money does not make you more powerfuly either, it's just shiny stuff i.e. again bragging rights.
Also, the game has completely eliminated RTM trading by introducing a second currency (Doubloons) that is used as micro-payment to unlock certain aspects of the game. This replaces the monthly fee, but at the same time, Doubloons can be traded in an open in-game market for the regular in-game currency, with prices adjusting to supply and demand. If you don't have the skills and don't want to grind for money, you can buy lots of Doubloons directly from the game company and exchange them for in-game money on the market. Voila, an official alternative for RTM that does not introduce inflation (due to the unfixed market price for Doubloons)
Isn't it a moral imperative in a capitalistic society for the smart to profit off the stupid?
No. Capitalism concerns itself with economical imperatives, not morals. What you're thinking about is Social Darwinism. The two are not the same, despite the attempts of many to blur the distinction.
Yeah, the best possible world is one where everyone is armed and knows everyone else to be armed so that anyone having a bad day or misjudging a situation turns into a major bloodbath.
d ex.htmli ndex.html
http://www.cnn.com/2006/US/11/22/woman.shot.ap/in
http://www.cnn.com/2006/US/11/25/nyc.shooting.ap/
Which had a lot of history to recommend it -- pretty much every time in history Germany was unified a big war broke out.
That's about as idiotic a statement as is possible to make. Germany was unified for the first time in 1870, AFTER Prussia won a war against France and thereby gained enough clout to make it happen. It stayed unified for 75 years, through the two world wars. It was unified the second time in 1990, with no war to follow.