Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3695736
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T04:39:14+00:00 2026-05-19T04:39:14+00:00

Jon Skeet reports today ( source ) that : Math.Max(1f, float.NaN) == NaN new[]

  • 0

Jon Skeet reports today (source) that :

Math.Max(1f, float.NaN) == NaN
new[] { 1f, float.NaN }.Max() == 1f

Why?

Edit: same issue with double also!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T04:39:15+00:00Added an answer on May 19, 2026 at 4:39 am

    As others have posted, I tweeted one sort of "why" – in that it’s using IComparable as documented.

    That just leads to another "why" though. In particular:

    Console.WriteLine(Math.Max(0, float.NaN));  // Prints NaN
    Console.WriteLine(0f.CompareTo(float.NaN)); // Prints 1
    

    The first line suggests that NaN is regarded as being greater than 0. The second line suggests that 0 is regarded as being greater than NaN. (Neither of these can report the result of "this comparison doesn’t make sense", of course.)

    I have the advantage of seeing all the reply tweets, of course, including these two:

    It may seem unusual, but that’s the right answer. max() of an array is NaN iff all elements are NaN. See IEEE 754r.

    Also, Math.Max uses IEEE 754r total ordering predicate, which specifies relative ordering of NaN vs. others.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Jon Skeet posted this blog post , in which he states that he is
This question is inspired by Jon Skeet's answer: Is there a c# equivalent to
Jon Skeet has the following reputation tracker which is built by C#. I am
Jon Skeet spoke of the complexity of programming dates and times at the 2009
Jon Skeet made a comment (via Twitter) on my SOApiDotNet code (a .NET library
From Jon Skeet's blog: What does the following comment mean? // The line below
From Jon Skeet's wonderful book C# In Depth, First Edition : class Film {
This is taken from Jon Skeet's excellent personal C# site ( http://www.yoda.arachsys.com/csharp/ ): StringBuilder
I'm reading through Jon Skeet's book reviews and he is going over the numerous
In this question @Jon skeet referenced this old blog post by the authority Chris

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.