Click here to Skip to main content
15,912,072 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.

 
GeneralRe: What the NaN? Pin
Mladen Janković2-Oct-16 10:11
Mladen Janković2-Oct-16 10:11 
GeneralRe: What the NaN? Pin
BillWoodruff2-Oct-16 11:39
professionalBillWoodruff2-Oct-16 11:39 
GeneralRe: What the NaN? Pin
Nagy Vilmos2-Oct-16 7:10
professionalNagy Vilmos2-Oct-16 7:10 
GeneralRe: What the NaN? Pin
Cornelius Henning2-Oct-16 7:36
professionalCornelius Henning2-Oct-16 7:36 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 8:49
professionalSander Rossel2-Oct-16 8:49 
GeneralRe: What the NaN? Pin
Jochen Arndt2-Oct-16 10:22
professionalJochen Arndt2-Oct-16 10:22 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 10:33
professionalSander Rossel2-Oct-16 10:33 
GeneralRe: What the NaN? Pin
BillWoodruff2-Oct-16 12:23
professionalBillWoodruff2-Oct-16 12:23 
Sander Rossel wrote:
NaN will behave differently, feels very random.
Sander, this is a brilliant idea you've come up with; I'll offer a quick sketch, and look forward to your comprehensive implementation:
C#
namespace CatState
{
    public static class CatStateExtensions
    {    
        public static double CatDead(this double[] args)
        {
            if (args.Contains(double.NaN))
            {
                Random rnd = new Random((int) DateTime.Now.Ticks);

                return (rnd.Next(0,2) == 0)
                    ? double.PositiveInfinity
                    : double.NegativeInfinity;
            }

            return args.Min();
        }

        public static double CatAlive(this double[] args)
        {
            if (args.Contains(double.NaN))
            {
                Random rnd = new Random((int) DateTime.Now.Ticks);

                return (rnd.Next(0,2) == 1)
                    ? double.PositiveInfinity
                    : double.NegativeInfinity;
            }

            return args.Max();
        }
    }
}
The half-dead cats fighting over half-dead fish-heads have been keeping me up nights, lately.
«There is a spectrum, from "clearly desirable behaviour," to "possibly dodgy behavior that still makes some sense," to "clearly undesirable behavior." We try to make the latter into warnings or, better, errors. But stuff that is in the middle category you don’t want to restrict unless there is a clear way to work around it.» Eric Lippert, May 14, 2008

GeneralRe: What the NaN? Pin
Mladen Janković2-Oct-16 12:40
Mladen Janković2-Oct-16 12:40 
GeneralRe: What the NaN? Pin
BillWoodruff2-Oct-16 16:17
professionalBillWoodruff2-Oct-16 16:17 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 20:34
professionalSander Rossel2-Oct-16 20:34 
GeneralRe: What the NaN? Pin
Jochen Arndt2-Oct-16 15:04
professionalJochen Arndt2-Oct-16 15:04 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 20:36
professionalSander Rossel2-Oct-16 20:36 
GeneralRe: What the NaN? Pin
Jochen Arndt2-Oct-16 23:20
professionalJochen Arndt2-Oct-16 23:20 
GeneralRe: What the NaN? Pin
harold aptroot2-Oct-16 11:02
harold aptroot2-Oct-16 11:02 
GeneralRe: What the NaN? Pin
Mladen Janković2-Oct-16 11:04
Mladen Janković2-Oct-16 11:04 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 11:13
professionalSander Rossel2-Oct-16 11:13 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 11:19
professionalSander Rossel2-Oct-16 11:19 
NewsRe: What the NaN? Pin
Super Lloyd2-Oct-16 12:02
Super Lloyd2-Oct-16 12:02 
GeneralRe: What the NaN? Pin
BillWoodruff2-Oct-16 16:22
professionalBillWoodruff2-Oct-16 16:22 
GeneralRe: What the NaN? Pin
Super Lloyd2-Oct-16 19:28
Super Lloyd2-Oct-16 19:28 
GeneralRe: What the NaN? Pin
Sander Rossel2-Oct-16 20:38
professionalSander Rossel2-Oct-16 20:38 
GeneralRe: What the NaN? Pin
den2k882-Oct-16 20:59
professionalden2k882-Oct-16 20:59 
GeneralRe: What the NaN? Pin
BillWoodruff3-Oct-16 0:33
professionalBillWoodruff3-Oct-16 0:33 
GeneralRe: What the NaN? Pin
den2k883-Oct-16 1:53
professionalden2k883-Oct-16 1:53 

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.