- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
22.0f/3 was quite a common way of representing PI in a rough way before frameworks came long and stuck 'official' PI constants in.
Admin
In the India we using 22/7, no 22/3.
Thank you, come again!
Admin
As far as pointless boolean synonyms go, "YOUBET" is a new one.
Admin
Admin
Admin
You can usually spot them by checking for anyone who is coding for web sites.
Admin
I like the graveyard of bad ideas. I might steal that.
Admin
I'd be willing to bet that this guy (gal?) got better grades in English class than in Math class.
Admin
I had a math teacher in middle school who (briefly) insisted that 22/7 is an exact representation of pi.
Perhaps she should have looked up what "irrational number" means...
Admin
Admin
Either that, or "355./113". It's only 1 character longer than "22.0f/3" and it's accurate to 6 decimal places.
Admin
Gentlemen, we are within inches of developing the technology to properly handle True, False, FileNotFound.
Admin
The left out 'Yowzah!' as a possible TRUE value.
Admin
Admin
I don't see a problem with the C# rounding routine. AFAIR, C# doesn't offer a "round to {x} decimal places" and has a major gotcha in the official rounding routine.
Admin
Round isn't actually that bad. It's a way to replace C#'s default rounding "half towards even" with a more conventional "half towards up".
The real WTF is why would anyone want to use banker's rounding as a default method. http://msdn.microsoft.com/en-us/library/aa340227(v=vs.71).aspx http://en.wikipedia.org/wiki/Rounding#Round_half_to_even
Admin
Never has a comment on this site been more FileNotFound. You should be AdjectiveNotFound of yourself.
Admin
Yeah, apart from the missing '+' it seemed fairly reasonable to me. There are valid reasons for wanting to write your own rounding routine-- for example, in many financial applications, it is desirable to add something like 0.5000000001 instead of 0.5 to keep floating point error from causing the result of some calculations to round down erroneously.
Admin
Err...I come from a universe where different physical laws apply <shuffles away quietly>
Admin
When you're working with crazy stuff like PI, close enough has got to be good enough. You're never going to get it perfect.
And I mean never as in universe freezes solid type of never.
Admin
The filexists function can be explained by print statement debugging.
Admin
Admin
Admin
Admin
use only oracle floats!
Admin
Admin
Not until the Deluge, at least. Heyo!
Admin
Nor today, if you have Prof. Frink teaching you: http://www.youtube.com/watch?v=O-Y-ua3WBi4
Admin
Admin
Admin
{"Maybe",TIME[7]&1}
I see no problem with the computer making a decision for you if you're waffling. This is a solid implementation of "Maybe."
Admin
Please tell me this is a joke.
(Just in case it isn't: don't use floating point for financial crap)
Admin
Admin
My Initial troll post finally wins.
Admin
Maybe is Prof. Alan Turing's engine. Read computer history to get knowledge like me.
Admin
I disagree. Perhaps PI is not really constant throughout all time and positions in the infinite universe? Perhaps it is changing ever so slightly, so slow that in all of human history and in our galaxy, the change would be undetectable. At some point in time and space, it very well could be 3.
Admin
Admin
To understand recursion, you must first understand recursion.
Admin
The code above actually has a typo. It should read "YOUBETCHA" instead of "YOUBET". It was part of the Minnesota release.
Admin
I walk on water all the time. From late December to about March.
Admin
Ooh, I know how to fix this code. Works as advertised:
// Convert to negative number
varInt := StrToInt('-1');
Admin
And that's one of the reasons that Texas will not implement Obamacare: we don't need the Federal Government telling us what PI is and how it should be calculated and what we are and are not allowed to do with our Mexican slaves.
Admin
With the boolean table, can a jokey Easter egg be considered a WTF? Personally I live the implementation of maybe.
The round function is just fine. And you may indeed find uses for floats in financial software, some of them may even be legal!
Admin
You can get this code to fail:
Simply pass in "null".
Admin
x=atan(1)*4
is perfect!
Admin
I like how it's apparently more reasonable to invoke changing universal constants than it is to consider that the book might just have been describing a shitty engineer.
Admin
At the risk of being mildly serious: The Bible gives the measurements of a certain object, mentioning that the diameter is 10 and the circumference is 30.
(a) There is no such thing as an "exact measurement"; there is only measurement within a certain precision. This is commonly discussed in science classes under the heading "significant figures" -- feel free to google the phrase for details. As the quote is not from a scientific treatise but from a general discussion of the furniture in a certain building, the writer does not tell us the number of significant digits, but it's likely 2 or maybe only 1 (given that both numbers are multiples of ten). If you perform an arithemtic calculation on two numbers and the least accurate has only one significant digit, the answer is only meaningful to one significant digit. If the writer had said that he measured the circumference as 10 cubits accurate to 1 significant digit, and then concluded that the circumference was 31.42 cubits, he would have been marked wrong in my chemistry and physics classes.
Indeed, when I took chemistry in college, we had a question on a test that said you have a beaker with 40 g of water, you add .01 g of salt, what is the weight of the resultant mixture? The correct answer was 40 g. Students who wrote 40.01 g were marked wrong, because they had failed to understand the concept of significant figures.
In this case, 10 * 3.14159... = 30 -- one significant digit -- not 31.4159. You can't invent additional precision out of thin air.
(b) Even ignoring that this is a physical measurement and therefore inherently an approximation, pretending it's a question in abstract geometry, please tell me what you think the "correct" answer is. If you say 31, you are no better than the original writer: pi is no more equal to 3.1 than it is to 3. If you say 31.4, that's not an exact value for pi either. You could give 100 digits and it still wouldn't be exact. No matter how many digits you give, you will not be stating the exact value for pi. The only way to exactly state the value of pi is to say "pi" or give an algorithm. I suppose the writer could have said that the circumference was "10 times pi", but that just leaves it to the reader to do the calculation himself.
So you're ridiculing the Bible for, (a) failing to ignore the concept of significant figures, and (b) failing to ignore the fact that pi is a transcendental number. Apparently Moses understood science better than you do.
Admin
Perhaps the last file_exists encapsulation required a strict 0/1 type instead of a true/false return. You could do it in one line with type casting, but without knowing all the requirements, it could have been perfectly valid.
Admin
Pi in the bible, come on guys. This brillant bit comes from creationists:
So yes, 30 cubits / 10 cubits = 3. And now their Jesuit escape This comes from people who take the Bible literally. Is this bigotry the original WTF for which Jesus died at the cross?Anyway, they do show us good use of the C# rounding routine in Biblical times...
Admin