- 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
frist
Admin
The VB.Net submission is perfectly valid, written in C# it would look like this:
public class UserSession : UserSession<UserSession> { ... }
Admin
Yeah, and in the CRTP as well. The Curiously Recurring Template Pattern, a C++ thing where a class derives from a template class using the derived class as a template parameter.
https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
Admin
It's no longer 1950. Please don't shout Lisp.
Admin
Well, actually there's a bit more to SQL Server Reporting Services and the accompanying designer than "If you can use Excel, you can create reports". The fact that you can script the behavior of elements is quite useful and it is more than just VBA - it is actually VB.NET (have you ever tried to display Code128 barcodes on an invoice...?).
However, this code snippet shows exactly what happens when you let someone who thinks he knows Excel create a SSRS report with the report designer...
Admin
It seems LISP could stand double the amount of nested parentheses.
https://github.com/syl20bnr/spacemacs/issues/6287
And for the sake of nitpicking: that's not about LISP itself, but the machine interpreting it.
In response to AlexMedia:
do you mean the VB.NET code is valid as VB code, or valid as WTF? (Both are acceptable)
You can even declare a variable with that name that is different from all those classes:
Private UserSesson As UserSession
This reminds me of my first experiences with BASIC, where A, A$, A(), A$() referred to different entities each.
In one of our product we still have tons of legacy code where an amount of zero means that something isn't available or isn't chosen.
So what to do if 0.00 € is a valid amount to be calculated with? And Nullable<T> hasn't been invented yet?
Simple:
amount = 0.00001; // the rounding on output will take care of those small amounts
The code in this example is more elegant for it uses a constant for it. I really should suggest to introduce a constant:
const double zeroAmount = 0.00001;
Admin
ZERO = 0.1f
for when you want to divide by zero without getting an error
Admin
Or in a numerical analysis code when you want to see if there's convergence as in: if (abs(lastIteration - thisIteration) < ZERO) ;-)
Admin
Hah! I like your thinking. The real reason was much more mundane but it isn't as funny if I explain it...
Addendum 2016-09-06 10:11: OK, I guess I will.
The function this came from is controlling a device - the number "ZERO" is being compared to is a derivative of the reading from the device. Since there are things like noise, sampling errors, calibration errors, etc. 0.01f is good enough in context to say the device has stopped moving.
I will just say that this line of code is one from an end product that costs the U.S taxpayers $17 billion. If you knew what the device was and you paid any of that money, you would be weeping right now.
Admin
In numerical analysis, you don't use the word ZERO for "close enough", you call it EPSILON.
Admin
But EPSILON is Greek, and nobody wants that. And doesn't ZERO sound far more enterprisey?
Admin
Well, if we are getting into origins of words, there's a documented and somewhat tortured path from "zero" back to an Arabic word. Take that for what it's worth, which admittedly isn't much.
Admin
Was about to write thia one myself. Although, 0.01 seems huge for such purposes, even if we are talking 2B floats. Also, I prefer to call it epsilon so you can have fus=ro/(dah+ epsilon);
This is very common in code where performance matters to the point where you cannot afford branching when you do a divisuon and precision is wibbly-wobbly anyways, like computer games.
Admin
Makes sense, since it was the Arabs that introduced the concept of zero, which was unknown to the Greeks and Romans at the time.
Admin
Very much THIS. Code which is fragile with respect to true "zero" should oughtta be written with either #def EPSILON machine.eps (or equivalent) or with nice clean if x < $SMALL_VALUE then {don't try to calculate y/x or log(x) }
And yet, some nonvanishingly small number of questions on StackOverflow ask why the user can't get float(x) == float(y) to be TRUE when it should be. Sigh.
Admin
Nearly all sources on the InterTubes disagree. It was almost certainly folks on the Indian Continent who got it first. https://en.wikipedia.org/wiki/0_(number)#History
Admin
SSRS can be used as an end-user tool, or as a developer tool with some powerful features, including being able to add your own .DLLs, custom functions, etc. This is an example of how their .Net based expression syntax can be abused though (it is annoying at times).
The worst problem with this example is that SSRS provides a way to handle this multiple-if-then-else logic in an expression. It gives you a function called Switch that lets you pass "unlimited" pairs of arguments where the first is a Boolean expression, and the second param being the value to return. No need to nest parenthesis, just to make sure you put commas between them.
Still, doing that in a function is really a WTF in the first place, but these are expressions not functions so everything has to be inline (use a different part if you want to write your own function that can then be called in-line)
Admin
Trust me, referencing Wikipedia as your source material doesn't help much. I have seen several times where something is factually wrong, but keeps being set that way because it can be referenced at a number of "reliable sources".
Admin
While Indians were the first to use zero, the concept was transmitted to Europe via Arab scholars. From the same page you cite:
Admin
I've seen several places that suggest the Mesopotamians had the idea of a zero around 3,000BC (which made its way to India and then back to Europe, this taking 4,000 years to make it this far North), and the Mayans developed it around 30BC.
Admin
Even weirder when FP values ARE exactly equal when you don't expect them to: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=781997
Admin
A hammer?
Admin
Even if someone doesn't like the word 'epsilon', not one iota will be changed about the fact that ZERO should be equal to 0. https://www.vocabulary.com/dictionary/iota https://en.wiktionary.org/wiki/iota#Noun
Admin
One thing the professors used to repeat ad nauseam was "Floating point values are never equal, if they are, you probably have a bug, most likely = instead of == somewhere". Good rule of thumb, even if obvious exceptions exist.
Admin
My much senior colleague wrote
into his "framework". Intentionally... So you see, there is many uses for non-zero zeros.
Admin
I can't tell you what the rest of the function does. But I will tell you that I have been writing software for the government for almost 20 years now, and the mere existence of this function is the biggest WTF I have ever encountered. And this is government work, so that's saying something.
Admin
So... it is either involved in avionics or the email server for the Secretary of State.
Admin
I agree from alpha to omega. There really is a delta between zero and epsilon, even if it's smaller than a mu.
Admin
Seems Nanis found a citing (same one you did?), but I didn't need one. It was the Arabs who introduced the concept of zero to Europeans -- which includes the Romans and Greeks in addition to the Spaniards -- and that none of these cultures had a representation of zero in their numbering systems until it was brought to them by the Moors. Pay attention in history class and you too can be a Moorish Wizard!
In Roman numeral math prior to the 12th century AD, one could represent "10 - 5" as "X - V" with a result of "V", but "X - X" was just about as impossible then as division by zero is for us now. The answer cannot be represented -- there was no zero. Curiously, it is for the same reason division by zero is not possible: The exact number of times the value zero can be subtracted from any value cannot be represented.
Admin
No, division by zero is not possible because multiplication by zero isn't bijective, and therefore its inverse doesn't exist. If it was just about "representation" then someone would invent a symbol for it (and indeed people have done so, but the resulting system isn't consistent with the conventional laws of arithmetic).
Admin
Roman numerals were used for writing numbers in text. They were not used for calculation. In trigonometric or astronomical tables were high precision fractions were needed the ancients used various variations of positional notation, usually with Greek numerals, and they absolutely used symbols for zero; see for example https://en.wikipedia.org/wiki/Ptolemy%27s_table_of_chords and https://en.wikipedia.org/wiki/Greek_numerals.
Admin
Someone's been spying on my code !!
That die ASP VB function looks exactly like my die(s) function, it even uses s for the message ;)
(Mine is till in active use in some old code still lingering within one of our applications, going for it's 17'th year soon)
Admin
Yes, they did. AFTER they learned about zero from the Arabs.
Admin
This? https://en.wikipedia.org/wiki/Homogeneous_coordinates