Click here to Skip to main content
15,909,199 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralWhat the NaN? Pin
Sander Rossel2-Oct-16 5:45
professionalSander Rossel2-Oct-16 5:45 
GeneralRe: What the NaN? Pin
Richard MacCutchan2-Oct-16 6:01
mveRichard MacCutchan2-Oct-16 6:01 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 6:12
professionalSander Rossel2-Oct-16 6:12 
GeneralRe: What the NaN? Pin
Florian Rappl2-Oct-16 6:42
professionalFlorian Rappl2-Oct-16 6:42 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 8:34
professionalSander Rossel2-Oct-16 8:34 
GeneralRe: What the NaN? Pin
Florian Rappl2-Oct-16 20:17
professionalFlorian Rappl2-Oct-16 20:17 
GeneralRe: What the NaN? Pin
Richard MacCutchan2-Oct-16 6:52
mveRichard MacCutchan2-Oct-16 6:52 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 8:44
professionalSander Rossel2-Oct-16 8:44 
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... Smile | :)

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 Unsure | :~

Luckily, I've never had to work with NaN in C# because why would there even be a NaN anyway...
Read my (free) ebook Object-Oriented Programming in C# Succinctly.
Visit my blog at Sander's bits - Writing the code you need.
Or read my articles here on CodeProject.
Simplicity is prerequisite for reliability.
— Edsger W. Dijkstra
Regards,
Sander

GeneralRe: What the NaN? Pin
Mladen Janković2-Oct-16 9:54
Mladen Janković2-Oct-16 9:54 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 10:13
professionalSander Rossel2-Oct-16 10:13 
GeneralRe: What the NaN? Pin
Mladen Janković2-Oct-16 10:24
Mladen Janković2-Oct-16 10:24 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 11:05
professionalSander Rossel2-Oct-16 11:05 
GeneralRe: What the NaN? Pin
Mladen Janković2-Oct-16 12:33
Mladen Janković2-Oct-16 12:33 
GeneralRe: What the NaN? Pin
Richard MacCutchan2-Oct-16 22:41
mveRichard MacCutchan2-Oct-16 22:41 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 22:51
professionalSander Rossel2-Oct-16 22:51 
GeneralRe: What the NaN? Pin
Richard MacCutchan2-Oct-16 22:54
mveRichard MacCutchan2-Oct-16 22:54 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 23:20
professionalSander Rossel2-Oct-16 23:20 
GeneralRe: What the NaN? Pin
Richard MacCutchan2-Oct-16 23:30
mveRichard MacCutchan2-Oct-16 23:30 
GeneralRe: What the NaN? Pin
Sander Rossel3-Oct-16 6:00
professionalSander Rossel3-Oct-16 6:00 
GeneralRe: What the NaN? Pin
Richard MacCutchan3-Oct-16 6:21
mveRichard MacCutchan3-Oct-16 6:21 
GeneralRe: What the NaN? Pin
Theraot4-Oct-16 1:33
Theraot4-Oct-16 1:33 
GeneralRe: What the NaN? Pin
Herbie Mountjoy4-Oct-16 2:25
professionalHerbie Mountjoy4-Oct-16 2:25 
GeneralRe: What the NaN? Pin
Richard MacCutchan4-Oct-16 3:42
mveRichard MacCutchan4-Oct-16 3:42 
GeneralRe: What the NaN? Pin
Richard MacCutchan4-Oct-16 6:13
mveRichard MacCutchan4-Oct-16 6:13 
GeneralRe: What the NaN? Pin
Sander Rossel4-Oct-16 8:02
professionalSander Rossel4-Oct-16 8:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.