|
glennPattonInThePUB wrote: Hi All,
Return to working mode, Clean shirt, Clean trousers, have shave, [Coffee] go!
When confronted by management, just think, What Would Mick Do...then probably do the opposite.
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|
|
Good luck for you first day in the new job - hope it all goes well!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Control to Glenn, you're good to go!
veni bibi saltavi
|
|
|
|
|
Good luck!
By the way, you work in a PUB!?
Maybe it's time to change your screen name
|
|
|
|
|
Well done, hope they pay reasonably well and you enjoy the work.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Congratulations!
glennPattonInThePUB wrote: Clean shirt, Clean trousers, have shave, [Coffee] go
No, don't do any of this. Make them feel that you are really underpaid.
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
Just as long as they don't require you to provide breakfast for the office on Friday of your first week.
"Rookie Breakfast", yeah that's a think at one company I worked for.
|
|
|
|
|
var result = new[] { 1, double.PositiveInfinity, double.NegativeInfinity, double.NaN }.Max();
var result = new[] { 1, double.PositiveInfinity, double.NegativeInfinity, double.NaN }.Min();
var isNaNSmaller = double.NaN < 1; So NaN is not the biggest value, it's still bigger than one, but it's also the smallest value.
I hate to sound infinitely negative, but that's messed up
|
|
|
|
|
NaN means Not a Number, so you cannot compare it to a proper number and get a valid response.
|
|
|
|
|
I know, so always treat it as smallest value, or always as biggest value or, better yet, throw an exception when comparing it to numbers.
These results are contradictory and just don't make any sense at all!
If this was JavaScript I'd be okay with it, but we're talking C# here. I expected better from C#
|
|
|
|
|
This has nothing to do with C#. I refer you to IEEE 754.
|
|
|
|
|
I'm glad that a lot of people have thought about how NaN should have contradictory results in different usages
<Edit>
So it seems the contradictory result are in IEEE 754, but the weird behavior in Min and Max is Microsoft[^]
</Edit>
modified 2-Oct-16 17:16pm.
|
|
|
|
|
That is true. But keep in mind that the Min and Max functions have nothing to do with C# - they are written in C#; yes, but they are part of the LINQ / the .NET Framework.
The difference in both is that Max excludes NaN, while Min will take NaN exclusively. You can see the difference here (Min)[^] and here (Max)[^].
That is different to some JS functions (such as everything in Math), which are defined by the same specification as the language.
|
|
|
|
|
"Not a number" means exactly that. So you cannot equate it to any numeric value.
|
|
|
|
|
Richard MacCutchan wrote: So you cannot equate it to any numeric value Yes you can, and that's the point.
I expected either an exception (compile or run time) or at least a predictable weird behavior (well, it's predictable once you know all the edge cases I guess).
Now whether you should is a different discussion...
I found this because I had some weird JavaScript bug by the way, casting some object to a number results in NaN and I was wondering how C# handled the case the followed.
NaN is not smaller than 1 (when comparing and when using the Min function), but when both are thrown into the Max function NaN is smaller than 1. Got it
Luckily, I've never had to work with NaN in C# because why would there even be a NaN anyway...
|
|
|
|
|
Sander Rossel wrote: why would there even be a NaN anyway...
- 0/0
- ∞/∞
- ∞+(-∞)
- √-1
- and so on...
Just because you are not familiar with the subject, does not make others wrong.
|
|
|
|
|
0/0 should throw a DivideByZeroException (which it does for integers).
And apparently 1/0 equals infinity.
Now what is it? NaN, infinity or just plain not possible?
Doesn't it sound weird (and, indeed, very wrong) that a NUMERIC type has a value "NOT A NUMBER"!?
Anyway, when I said "why would there even be a NaN anyway" I was referring to NaN in actual real life business cases that make sense and have practical use
|
|
|
|
|
I would recommend you to this article before you continue your rant about IEEE754.
|
|
|
|
|
Tried to read it once, but to me it makes as much sense as the whole NaN implementation: none whatsoever (and I admit my limited math skills are to blame).
However, I tried reading the NaN part and what they basically say is that in some edge cases you don't want computations to stop (throw exceptions) when some bogus values are inserted (e.g. divide by 0). The workaround without NaN would be to catch exceptions and simply try again. Unfortunately, every language handles exceptions differently so they standardized on NaN.
Awesome, they destroyed our numeric system to support some edge cases (correct me if I'm wrong)
Luckily .NET offers some sensible numeric types with int, long and decimal
Unfortunately, I'm currently working in JavaScript, with floating point arithmetic, where NaN is quite common, and 0.1 + 0.2 equals 0.30000000000000004 (yes, I know that's IEEE754, but that doesn't make it right)
|
|
|
|
|
Sander Rossel wrote: they destroyed our numeric system to support some edge cases
Any representation of real numbers in computer memory will destroy 'numeric system' since you're trying to represent infinite set with finite amount of memory.
Sander Rossel wrote: Luckily .NET offers some sensible numeric types with int, long and decimal
decimal comes with performance costs as it has no support in hardware so it might not be suitable as a replacement in fields that traditionally use floating point arithmetic. It is meant to be used for financial stuff since IEEE754 is not suitable for that purpose, so not everyone have to invent their own way of doing math.
Sander Rossel wrote: 0.1 + 0.2 equals 0.30000000000000004
That's the problem with converting real numbers between different bases.
|
|
|
|
|
Sander Rossel wrote: And apparently 1/0 equals infinity. No, it does not, and never has.
|
|
|
|
|
double x = 1;
double y = 0;
double z = x / y; Yes it does
I'm not making this stuff up, you know (IEEE does that).
|
|
|
|
|
No it doesn't, 1/0 is undefined (i.e NaN) and always has been. Various computer systems may try to represent it by some very large or very small value, but that does not alter the fact that it has no mathematical value.
|
|
|
|
|
Really man, I completely agree with you there, but .NET (and I guess IEEE) represents 1 / 0 as Infinity and 0 / 0 as NaN. And Infinity behaves different than NaN, so they're not the same (according to .NET/IEEE) no matter what we think of it
|
|
|
|
|
Sander Rossel wrote: .NET (and I guess IEEE) represents 1 / 0 as Infinity No, it does not, where on earth did you get this idea from? How exactly do you represent infinity as a number in a computer?
|
|
|
|