The Artima Developer Community
Sponsored Link

.NET Buzz Forum
System.Double.Epsilon con un pizzico di surreale

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Adrian Florea

Posts: 206
Nickname: adrian11
Registered: Jul, 2004

Adrian Florea is a .NET developer from Italy
System.Double.Epsilon con un pizzico di surreale Posted: Sep 8, 2005 9:35 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Adrian Florea.
Original Post: System.Double.Epsilon con un pizzico di surreale
Feed Title: Web Log di Adrian Florea
Feed URL: /error.aspx?aspxerrorpath=/adrian/Rss.aspx
Feed Description: "You know you've achieved perfection in design, not when you have nothing more to add, but when you have nothing more to take away." Antoine de Saint-Exupery
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Adrian Florea
Latest Posts From Web Log di Adrian Florea

Advertisement

Per chi ha voglia di un pizzico di surreale, ecco uno snippet che mi ha fatto impazzire...

// foo.cs
//
// csc /d:DUMMY foo.cs # stampa False
// csc foo.cs # stampa True
 
using System;
using System.Diagnostics;
 
class Test
{
      [Conditional("DUMMY")]
      static void Dummy(double x)
      {
            x = x;
      }
 
      static void Main()
      {
            double x = Math.Pow(double.Epsilon, 2);
            Dummy(x);
            Console.WriteLine(0 < x && x < double.Epsilon);
      }
}

Questo codice stampa False se compilato col simbolo DUMMY e True in caso contrario, cioè l'espressione:

0 < x && x < double.Epsilon

ha valori diversi in base al fatto che Dummy (che in teoria non dovrebbe far nulla) venga chiamato prima o no...

Non ho ancora capito perché.

Read: System.Double.Epsilon con un pizzico di surreale

Topic: [Axinom] On-Demand Webcasts oder moderierte Vorstellung des Axinom CMS Previous Topic   Next Topic Topic: Microsoft DemoServers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use