When (n<0) won't do.

« Return to Article
  • foobar 2004-10-07 13:56
    Wow. <br> <br>I know the inevitable commentary will spring up about how the number is a double and might suffer from imprecision in comparisons. <br> <br>--but that still doesn't justify _this_. <br> <br>Wow.
  • Jack 2004-10-07 13:57
    And people question the fact that good programmers can easily outperform the bad ones by a factor of 5
  • xellos 2004-10-07 14:03
    The uncertainty that enters the picture when comparing two quantities whose difference is close to the limit of the double's representation still applies to this implementation; all the coder has done is to convert to a different representation of the number; that doesn't help any! <br> <br>The uncertainty itself is semantic; it's the difference between what you wanted to store in the number, and what actually got stored - no matter how you look at the stored number, the uncertainty doesn't change.
  • ifdef 2004-10-07 14:07
    Ken Arnold wrote this in August 1989 Unix Review and I quote: <br> <br>&quot;It is a little known fact that despite the commonality of two's-complement machines, there is some disagreement about the representation of some numbers. For example, on a two's complement machine, the representation of -1 is (in 8 bits) is 11111111, whereas in a one's complement machine it would be 10000001. <br> <br>Generally speaking, you cannot rely upon the underlying representation of even integers... <br> <br>Portability can be enhanced, therefore, if you don't use literal integers in your expressions, but use the conversion routines for symbolic names to prevent any mixup with the representation. For example, instead of the common i++; you should really say <br> <br> i += atoi(&quot;1&quot;);. <br> <br>If you pass in a string version of the number you want, the atoi() routine knows how to decode it into the true representation for the current machine. Similarly, for relative comparisons, you should say, <br> <br> if (count &lt; atoi(&quot;10&quot;)) <br> <br>This mechanism gives you maximum portability...&quot; <br> <br>:)
  • Chris R. Timmons 2004-10-07 14:12
    What language was this written in? It's kind of hard to tell when a &quot;C&quot;-like code snippet is posted. It almost looks like C#, except the line &quot;string nStr = n.ToString&quot; isn't valid C# code (missing the () after ToString), and the nStr variable is referenced as nstr (note the lowercase &quot;s&quot;).
  • mrd 2004-10-07 14:19
    Is -0.0 less than 0.0?
  • Dave Mays 2004-10-07 14:23
    I would guess it's badly transcribed C#.
  • Alex Papadimoulis 2004-10-07 14:28
    It's a strange error that occurs in the Screenshot-&gt;Text routine I use. It would seem that there are occasional typos. <br> <br>:-D
  • Phil Scott 2004-10-07 14:28
    It looks to me at a glance that it's only searching the first character for the negative sign too. If I'm not mistaken, the &quot;negative symbol&quot; appears to the right of the digits in some cultures. What these cultures are, well, I have no clue.
  • Christian Duhard 2004-10-07 14:28
    No idea what language this code is. <br> <br>If it's legitimate, wow.
  • Christian Duhard 2004-10-07 14:30
    Looks like the transcribed code ahas been fixed .. It's bad C# now.
  • Dave Mays 2004-10-07 14:36
    while(nstr != nStr) <br>{ <br>//noop <br>}
  • WanFactory 2004-10-07 14:50
    how about this instead :p <br> <br>bool IsNegative(double n) <br>{ <br> string nStr = n.ToString(); <br> double index = nStr.IndexOf('-'); <br> return !IsNegative(index); <br>} <br> <br>now that would be a mongo wtf
  • chandler 2004-10-07 14:58
    Does Java have -0.0? If so, what is the result of comparing that via d &lt; 0?
  • Guayo 2004-10-07 15:09
    You can't denie this little function really enhances readability like in: <br> <br>if (IsNegative(velocity)) <br>{ <br> throw new InvalidOperationException(&quot;Dude!... You are moving backwards!&quot;); <br>} <br> <br> <br>However I have a problem with the posted implementation as some already said, it could lead to i18n issues, besides... Why would someone transform that double to a string? I'm not talking about performance here ‘cause knowing that a value is negative is truly important so if it takes some time to know it IMHO all that time is worth it, I'm talking about something more important. As soon as non programmers see his code they going to believe programming it's easy, what wee need here is keep the algorithm in the mathematic domain. We don't need this people to come to our world. It's hard already with all that IT outsourcing going on. So what do you think about the following little refactoring? <br> <br>bool IsNegative(double n) <br>{ <br> return n * double.PositiveInfinity == double.NegativeInfinity; <br>}
  • JeffS 2004-10-07 15:13
    A definite WTF. <br> <br>By the way -- what if n is something like .00000000001? <br> <br>I believe the ToString method will generate something in the form of &quot;1.0E-17&quot; -- which this method would interpret as being a negative number since it contains a &quot;-&quot; symbol at any position.
  • Guayo 2004-10-07 15:28
    @JeffS <br>The function as it is would not return true for 1.0E-17 as it search for the little - at the first position. <br> <br>BTW, that's makes me see this function shouldn't compile in C# as there isn't an implicit conversion form int to bool in C# (IndexOf does return an int), so now I really doubt this is C# at all... maybe JScript.Net or something like that.
  • andrei 2004-10-07 15:52
    Both mrd and chandler raised an important question. <br> <br>I presume that C# implements IEEE 754 numbers, and therefore has both 0.0 and -0.0. An interesting property is that 0.0 == -0.0. <br> <br>The only way I know of telling the two apart, short of looking at the textual representation or bit pattern, is by checking the sign of 1/x (1/0.0 is infinity, 1/-0.0 is negative infinity.) <br>
  • Jeff S 2004-10-07 16:03
    I don't think this can be .NET .... because the answer would be reversed ! <br> <br>The IndexOf method in a string returns the position of the match if there is one (starting at ZERO for the first position in the string), or -1 if there is no match. <br> <br>So the expression returns 0 if there is a <br>&quot;-&quot; in the first position, or -1 if there is not ! <br> <br>And if -1 is returned by the expression, this function returns TRUE indicating that the number is negative! <br> <br>(Am I missing something here?) <br> <br>Wouldn't this cause the function to always return the OPPOSITE value of what it should? <br>
  • WanFactory 2004-10-07 16:04
    Aha! I found out why n &lt; 0 won't do... <br> <br>if n is negative infinity, n &lt; 0 will return true but the method above returns false. So if the intent of the function is to return true for ordinary negative numbers but not for negative infinity then its not a WTF, just a badly named function.... <br> <br>This has got to be my new all-time favorite blog...
  • Guayo 2004-10-07 16:23
    Yeah... this seems to be more complicated of what I initially thought... there are too many questions, like: <br>Is this C#? (I strongly doubt) <br>Does this function returns true when n &lt;0? (Now it seems that it's just the opposite) <br>Does –0 &lt; +0? (my brains hurts by now)... <br>I think I just walk away and get some fresh air.
  • Wojo 2004-10-07 16:24
    But there are so many better ways to implement the method. <br> <br>Let's see... (using C# here) <br> <br>bool IsNegative(double d) <br>{ <br> return (Math.Abs(d) != d); <br>} <br> <br>bool IsNegative(double d) <br>{ <br> return (Double.IsNaN(Math.Sqrt(d))); <br>} <br> <br>bool IsNegative(double d) <br>{ <br> int n = Math.Ceiling(d); <br> try <br> { <br> Object[] o = new Object[n]; <br> } <br> catch (ArgumentOutOfRangeException e) <br> { <br> return true; <br> } <br> return false; <br>} <br> <br>...What? Am I missing something? :-)
  • Guayo 2004-10-07 16:45
    LOL @Wojo implementations, but joking aside you need to cast to decimal on some of your functions there and take care of those pesky OverflowExceptions that may happen. <br> <br>@ Alex Papadimoulis, I think you should revert the changes in the code as it's pretty obvious this is not C#.
  • Guayo 2004-10-07 16:51
    @Wojo... <br>damn it! disregard what I said of your code. I thought to remember Abs always returned a decimal when in fact does return a value of the type of the parameter. <br>So yes... your code rocks man. ;-)
  • Wojo 2004-10-07 17:19
    Guayo, no worries. I didn't try to even compile any of that, much less test it, so it wouldn't surprise me if there were bugs. :-) <br> <br>I actually caught one after posting. In the 3rd function, I think it should be Math.Floor instead of Math.Ceiling, since I think declaring an array of size 0 is legal in C#?
  • Hassan Voyeau 2004-10-07 17:33
    Assuming this is C#, why not just use the Sign function in the Math class???
  • Hassan Voyeau 2004-10-07 17:37
    FYI : [ <a target="_new" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemmathmemberstopic.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemmathmemberstopic.asp</a> ]
  • andy brummer 2004-10-07 18:59
    I'm sad to say that I've worked with a fellow developer that asked me how to tell if a number is negative. It took me a while to answer because I was flabergasted. When I answered less then zero. The wheels spun in their head and they thanked me. It wasn't until 5 minutes latter that they walked back and told me that it was a dumb question. <br>It's still better then the guy that couldn't figure out array indexing. All the table rows he output all had the same value. He couldn't grasp that arrays didn't increment like recordsets.
  • heywood j'blomi 2004-10-07 20:11
    <br>//return whether a double is less than Pi <br>bool IsLessThanPi(double n) <br>{ <br> return IsNegative(n - 3.1415926); <br>}
  • Zka 2004-10-08 02:09
    This is a crap! If the regional settings are different, negative numbers may be represented by parentheses, like (30). To avoid these conflicts, i suggest checking the sign of n*n, and if there is NO sign, n is negative. <br>LOL, WTF :]
  • Zka 2004-10-08 02:17
    Solution B. <br> <br>We all know that there are numbers that are positive, and some of them are negative. Sometimes a number is neither negative or positive. We have to sort these cases out! We should implement IsNegative in Pascal as follows: <br> <br>function IsNegative( n : double) : boolean; <br>begin <br> // i've revised your code, Steve, and i think <br> // you should use IF here! <br> Result := FloatToStr( n*n)[ 1] in ['0','1','2','3','4','5','6','7','8','9'] <br>end; <br> <br>function IsPositive( n : double) : boolean; <br>begin <br> Result := not( FloatToStr( n*n)[ 1] in ['0','1','2','3','4','5','6','7','8','9']) <br>end; <br> <br>function IsNegativeForReal( n : double) : boolean; <br>begin <br> Result := IsNegative( n) and (not IsPositive( n)); <br>end; <br> <br>function IsPositiveForReal( n : double) : boolean; <br>begin <br> Result := (not IsNegative( n)) and IsPositive( n); <br>end; <br> <br>function IsNegativeFinal2( n : double) : boolean; <br>begin <br> // this will work very stable <br> Result := IsNegativeForReal( n) and (not IsPositiveForReal( n)); <br>end; <br>
  • Zka 2004-10-08 02:21
    I forgot to use CASE! Steve will punish me! ;))))
  • The man with the mask ;-) 2004-10-08 04:07
    Back in the days, when you steel something your hand was removed for this terrible crime. In this case let's just stick to the fingers...
  • Sam 2004-10-08 04:15
    Zka: You do of course realise that N*N is ALWAYS POSITIVE.... (assuming N is a number and not NaN). <br> <br>?
  • Ray S 2004-10-08 04:41
    Hey, what's wrong with just doing a switch/select on all possible numbers? Since (I don't think) C# has this functionality, here it is in VB... <br> <br>Function IsNegative(n as double) as boolean <br>Select Case n <br> Case 0,0.000000000000001, 0.000000000000002, ... <br> Return false <br> Case -0.000000000000001, -0.000000000000002... <br> Return true <br> Case Else <br> Return &quot;WTF?&quot;.ToBoolean() <br>End Select <br>End Function
  • foxyshadis 2004-10-08 05:53
    Ray, just use one case for every possible number. =D <br> <br>Andy, maybe he worked in a language like PHP, where $array[] will add a new value (based on the largest current numberic key).
  • Alan Bellingham 2004-10-08 06:02
    OOo, sneaky. <br> <br>I notice you're not putting all the values in order - there's an infinite number of values missing just between the first two you list. <br> <br>(OK, so not really infinite, since no computer can deal with all real numbers.) <br> <br>BTW, Guayo, your function <br> <br> bool IsNegative(double n) <br> { <br> return n * double.PositiveInfinity == double.NegativeInfinity; <br> } <br> <br>should always return false, since the results of both sides will be NaNs, and NaNs never compare equal. Or perhaps this language actually break that rule? <br> <br>Nice idea, though.
  • Zka 2004-10-08 06:57
    Sam: i do :) But i tried to create a more f*cked-up version :)
  • Tony 2004-10-08 07:30
    I am speechless... <br> <br>Normally I would try to come up with a more f'ed up version of the code, but (and I respect the previous submissions) it isn't possible.
  • Dave M. 2004-10-08 08:09
    That's not a language that I'm familiar with (I didn't notice anyone identifying it above), but I do know that the hapless owner of this site has shown his ignorance again. <br> <br>Here's some Java that expresses why in many languages &quot;(n&lt;0) won't do&quot;: <br> <br>public class Foo { <br> public static void main(String... args) { <br> double d = -0d; <br> // Displays &quot;false&quot;, NOT &quot;true&quot;. <br> System.out.println(d &lt; 0d); <br> } <br>} <br> <br>Negative Zero is a legitimate quantity in many languages. Java is one of them. Possibly the one the quoted author uses is one of them. <br> <br>That said... it's still an iffy implementation. <br> <br>To the site owner: Please TELL US what language any given WTF is in. If you don't know, don't post it, because how the fuck are you supposed to know it's stupid if you don't know anything about the language? <br> <br>
  • Alex Papadimoulis 2004-10-08 08:26
    Whoa, it wasn't until Comment #40 that someone justified this. I see some people just aren't on the ball ;-)
  • nobody 2004-10-08 10:16
    The listed code seems to be C# because it uses IndexOf note the uppercase of the I and the O. <br>The ECMA-334 C# Language Specification requires the support of negative zero for doubles. &lt;a href=<a target="_new" href="http://www.jaggersoft.com/csharp_standard/11.1.5.htm&gt;reference">http://www.jaggersoft.com/csharp_standard/11.1.5.htm&gt;reference</a> here&lt;/a&gt;
  • Guayo 2004-10-08 10:23
    @Alan Bellingham <br>AFAIK... <br>NegativeInfinity != NaN <br>sqrt(-1) == NaN <br>1/0 == PositiveInfinity <br>-1/0 == NegativeInfinity <br>NegativeInfinity &lt; MinValue &lt; MaxValue &lt; PositiveInfinity <br>
  • Guayo 2004-10-08 10:25
    @nobody <br>It's not C# because nstr.IndexOf('-', 0, 1)) does not returns a boolean value... it could be JScript.Net
  • Guayo 2004-10-08 10:43
    @Dave M. <br>I didn’t get why are you being rude here. That implementation it’s stupid no matter what the language is, I think it was a great WTF. Knowing the language would be better and in some occasions it would be mandatory to know the language to see if a piece of code its WTF or not, this is not the case. <br> <br>BTW. I’m sure now this is not JScript.Net <br>
  • Alex Papadimoulis 2004-10-08 11:27
    This is C#. I just went back and looked at the original email. <br> <br>When typing out the screenshot, I also neglected to do &quot;==0&quot;. As if you can't tell from the spelling and grammar, I'm not a detail guy. <br> <br>Next time I'll just keep the screenshot. It's sad I get two typos in like 3 lines of code ;-).
  • Jeff S 2004-10-08 13:38
    So that explains it. The &quot;==0&quot; is critical to this function, as it is written! <br> <br>Because as I mentioned, without the &quot;==0&quot;, the function returns the OPPOSITE of what it says it does.
  • Miles Archer 2004-10-08 13:50
    Comment far above about velocity. Velocity is a vector quantity and can be negative. Speed is a scalar and cannot. <br> <br>The only way I can think of that would make sense of this would be for fractions or some other strange numeric system that is treated as strings. Ex. If you wanted to store 1.5 as &quot;1 1/2&quot; what's written would be a better way of determining a negative number than doing the lookup to find the numeric value and arithmetic.
  • me 2004-10-09 06:43
    actually i once managed to trick the basic interpreter on my commodore 64 to geneate -0 as result of some operation - which is case where this routing might be useful
  • fluffy 2004-10-10 11:28
    If you really want to include -0 as a negative number (even though it's mathematically nonsensical), just do something like: <br> <br>if (num &lt; 0.0 || num == -0.0) <br> <br>That assumes that 0 != -0.0 and makes no other assumptions about the various possible combinations of stupid comparisons between stupid non-numbers which only exist &quot;because they can.&quot;
  • andrei 2004-10-11 10:25
    &gt; That assumes that 0 != -0.0 <br> <br>Bad assumption, fluffy
  • init6 2004-10-11 18:44
    WTF! Oh come on now. Someone just made this up. I find it hard to believe anyone could be this stupid. Plus it's already a &quot;double&quot; so your compiler should be dealing with the 1's vs 2's compliment. <br> <br>I've maintained code for years and I have seen some bad code but this, Oh Sh*t it's probably real code. *scream* <br> <br>I'm going to go try to think up some way to profit from all the stupidity on this planet. Good day all.
  • ML 2004-10-13 05:30
    Why not simply converting the double value to binary then to string and checking whether the first character is a '1'? <br> <br>LOL
  • Stephen Holland, M.D. 2004-10-18 16:44
    The one's complement of -1 is 11111110 on an 8 bit machine.
  • SR 2004-10-27 13:23
    People, if -0.0 == 0 evaluates to TRUE, then -0.0 is NOT negative. A minus sign does not make a number negative; being strictly smaller than zero does (for real numbers). <br>As to Dave M's post about n &lt; 0: FALSE is what the program should print. -0.0 may be a legitimate representation of zero, but it is not negative. If you want to treat -0.0 as negative, then you are stretching the definition of 'negative' quite a bit.
  • mikeblas 2004-10-30 10:26
    I like reading code like this. Whenever I think the code will create an unneeded temporary object, either implicitly or explicitly, I take a swig from a flask that I keep in a drawer at my desk. <br> <br>Or, that I used to keep there, anyay. It got emptied. <br> <br>.B ekiM
  • jw 2004-11-04 09:49
    SR, floating point numbers != real numbers. (negative(r) &lt;-&gt; r&lt;0) =/=&gt; (negative(fp) &lt;-&gt; fp&lt;0) <br> <br>Hmmkay? &lt;/nit&gt;
  • Katja Bergman 2005-04-12 06:14
    I wonder if there could be a possible flaw in this solution. Isn't
    converting a number to a string dependant on the format settings
    defined in your system? What if you've defined a numerical format where
    the sign is actually put at the end of the number instead of the front?
    Thus -1 would convert to "1-"...<br>
    Very rare flaw, of course, if it would even occur. I think this
    ToString function is smart enough to ignore whatever format the user
    prefers and just uses the default format. [;)]<br>
  • yawmark 2005-04-12 10:45
    I must say, I do appreciate the irony that many students shy
    away from Computer Science because they fear the complicated math.
    <br>
    Funny, that's exactly why I avoided that major. Ah, well; we live, we learn.... :)<br>
    <br>
  • JJ 2005-04-12 16:05
    <P>Off the topic but I had a friend of mine who was in a beginning programming class and the instructor was discussing global variables. After a lengthily discussion on this topic another student chimed in and asked if they could explain it since he felt as if he had a complete grasp on the concept. What he said was astoundingly idiotic to say the least. Ready???? <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></P>
    <P>"So if I create a global variable in my application someone in <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /><st1:country-region w:st="on"><st1:place w:st="on">China</st1:place></st1:country-region> can see it." I don't think I need to say anymore.<o:p></o:p></P>
    <P>&nbsp;</P>
  • Schol-R-LEA 2005-04-12 16:21
    Anonymous:
    <p>Off the topic but I had a friend of mine who
    was in a beginning programming class and the instructor was discussing
    global variables. After a lengthily discussion on this topic another
    student chimed in and asked if they could explain it since he felt as
    if he had a complete grasp on the concept. What he said was
    astoundingly idiotic to say the least. Ready???? <o:p></o:p></p>
    <p>"So if I create a global variable in my application someone in <st1:country-region w:st="on"><st1:place w:st="on">China</st1:place></st1:country-region> can see it." I don't think I need to say anymore.<o:p></o:p>
    <br>
    </p>
    <p>You should have told them 'yes'. It's BS, of course, but at least they would have learned not to use globals. ;)<br>
    </p>
  • CornedBee 2005-04-14 19:37
    Anonymous:
    Ken Arnold wrote this in August 1989 Unix Review and I quote:
    <br>
    <br>"It is a little known fact that despite the commonality of
    two's-complement machines, there is some disagreement about the
    representation of some numbers. For example, on a two's complement
    machine, the representation of -1 is (in 8 bits) is 11111111, whereas
    in a one's complement machine it would be 10000001.
    <br>
    <br>Generally speaking, you cannot rely upon the underlying representation of even integers...
    <br>
    <br>Portability can be enhanced, therefore, if you don't use literal
    integers in your expressions, but use the conversion routines for
    symbolic names to prevent any mixup with the representation. For
    example, instead of the common i++; you should really say
    <br> <br> i += atoi("1");.
    <br>
    <br>If you pass in a string version of the number you want, the atoi()
    routine knows how to decode it into the true representation for the
    current machine. Similarly, for relative comparisons, you should say,
    <br>
    <br> if (count &lt; atoi("10"))
    <br>
    <br>This mechanism gives you maximum portability..."
    <br>
    <br>:)
    <br>
    <br>
    Curious. Many things about this.<br>
    First, 1's complement representation of -1 is 11111110, not 10000001. That would be Sign Bit representation.<br>
    Second, literal integers have nothing to do with their underlying
    representation. If the compiler doesn't convert the literal in the code
    correctly to the machine-specific representation, it's broken. Use a
    different compiler. If you compiled it for a different machine - let's
    just say that I severely doubt that there are or will be two CPU
    architectures with the same instruction set (making the code compiled
    for one run on the other) and different negative number representations.<br>
    <br>
    Somehow that makes me doubt the existence of this article.<br>
  • jspenguin 2006-01-15 16:37
    In Java you can do this:<br/>
    <pre>public boolean isNegative(double d) {
    long l = Double.doubleToLongBits(d);
    if (l&0x8000000000000000L) return true;
    return false;
    }</pre>
  • Fireblaze 2006-01-29 17:29
    A factor 10, according to Facts and Fallacies of Software Engineering by Robert L. Glass

    http://www.amazon.com/gp/product/0321117425/102-5616837-5488934?v=glance&n=283155


    "Something didn't quite work out ... "
    "- CAPTCHA Validation Incorrect"... WTF? LOL ;)
  • ObySamKenoby 2006-02-01 16:09
    Anonymous:
    Is -0.0 less than 0.0?
    <br><br>Well, it depends.... if you consider mathematical e (where if you take a number grater than 0 and small as you want, e is lesser than this number.... it is infinetly small) 0+e is represented as 0+ and 0-e is represented as 0-. <br><br>So we have:<br>0+ = +0.00000..... . . . .....0001<br>0- = -0.00000..... . . . .....0001<br>
    <br>If you consider only the first decimal (keeping the value) you have<br><br>0+ = +0.0<br>0- = -0.0<br><br>So 0.0 &gt; -0.0<br><br>OK, I'm already calling the asylum.:D<br><br>Samuele<br>
  • Loren Pechtel 2006-02-01 21:06
    Anonymous:
    while(nstr != nStr)
    <br>{
    <br>//noop
    <br>}
    <br><br>Well, many, many moons ago I wrote a short program and shook up every teacher in the department.<br><br>10 X = 3000000<br>20 X = X + 1<br>30 IF X < X + 1 GOTO 20<br>40 PRINT X<br><br>*EVERY* teacher insisted this was an infinite loop.  (The 3 million seed value is simply to make it terminate in a reasonable length of time.)<br><br>(This came up because the previous semester one teacher had given a final exam problem that had two logical approaches, one of which would fail for precision reasons--and there hadn't been a bit of discussion in class about precision issues.)<br>
  • Ulvhamne 2006-02-02 12:00
    <P>
    Anonymous:
    </P>
    <P>Well, many, many moons ago I wrote a short program and shook up every teacher in the department.<BR><BR>10 X = 3000000<BR>20 X = X + 1<BR>30 IF X &lt; X + 1 GOTO 20<BR>40 PRINT X<BR><BR>*EVERY* teacher insisted this was an infinite loop.&nbsp; (The 3 million seed value is simply to make it terminate in a reasonable length of time.)<BR><BR>(This came up because the previous semester one teacher had given a final exam problem that had two logical approaches, one of which would fail for precision reasons--and there hadn't been a bit of discussion in class about precision issues.)<BR>
    </P>
    <P>OH!</P>
    <P>Now that I quoted it. The code makes sense. Before, you couldnt see the "&nbsp;'less than' X + 1 GOTO 20" part of it. ;) Makes sense now that there is some kind of loop there .;)</P>
  • Pasa 2006-02-04 14:05
    <P>
    Anonymous:
    Ken Arnold wrote this in August 1989 Unix Review and I quote: <BR><BR>"It is a little known fact that despite the commonality of two's-complement machines, there is some disagreement about the representation of some numbers. For example, on a two's complement machine, the representation of -1 is (in 8 bits) is 11111111, whereas in a one's complement machine it would be 10000001. <BR>
    </P>
    <P>And he wrote it wrong: in one's complement the representation would be 11111110. And the 10000001 he issued is also an existing notation, but it's called 'signed magnitude'. </P>
  • Kuba Ober 2006-03-09 10:50
    I'd say that only if the representation has a notion of positive and negative zero, it would matter. If a number is stored as exponent plus a fractional 2s complement signed integer mantissa, there's no such thing as negative zero. There's only one zero, and it's commonly agreed upon that it's positive :)
  • mnebuerquo 2006-03-27 18:24
    <P>
    Anonymous:
    Ken Arnold wrote this in August 1989 Unix Review and I quote: <BR>...</P>
    <P>Portability can be enhanced, therefore, if you don't use literal integers in your expressions, but use the conversion routines for symbolic names to prevent any mixup with the representation. For example, instead of the common i++; you should really say <BR>i += atoi("1");. </P>
    <P>...</P>
    <P>This mechanism gives you maximum portability..." <BR><BR>:)
    </P>
    <P>I asked Google about Ken Arnold, and he seems to be someone who should know better. Is this article on the internet somewhere? If so, please post a link because I would like to read it in its entirety.</P>
    <P>Thanks</P>
  • Tangurena 2006-03-29 15:01
    <P>There is an old COBOL technique called "overpunched signed fields."</P>
    <P>When there wasn't room for -1234, you could use 123F instead. Where ABCDEFGHI in the last digit represented 0123456789 respectively, as well as indicated a negative number overall.</P>
  • Bullet 2006-04-07 11:40
    <P>
    Anonymous:
    Comment far above about velocity. Velocity is a vector quantity and can be negative. Speed is a scalar and cannot. <BR><BR>The only way I can think of that would make sense of this would be for fractions or some other strange numeric system that is treated as strings. Ex. If you wanted to store 1.5 as "1 1/2" what's written would be a better way of determining a negative number than doing the lookup to find the numeric value and arithmetic.
    </P>
    <P>&nbsp;</P>
    <P>Speed can be negative the same way that currency can be... When you are subtracting it... &nbsp; Negative currency means&nbsp;amounts that you owe someone, </P>
    <P>Negative speed means&nbsp;a chunk of speed that you "owe"&nbsp; - or will subtract in a calculation.&nbsp; <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction.&nbsp; In reality there is no such thing as negative... As </P>
  • Bullet 2006-04-07 11:40
    <P>
    Anonymous:
    Comment far above about velocity. Velocity is a vector quantity and can be negative. Speed is a scalar and cannot. <BR><BR>The only way I can think of that would make sense of this would be for fractions or some other strange numeric system that is treated as strings. Ex. If you wanted to store 1.5 as "1 1/2" what's written would be a better way of determining a negative number than doing the lookup to find the numeric value and arithmetic.
    </P>
    <P>&nbsp;</P>
    <P>Speed can be negative the same way that currency can be... When you are subtracting it... &nbsp; Negative currency means&nbsp;amounts that you owe someone, </P>
    <P>Negative speed means&nbsp;a chunk of speed that you "owe"&nbsp; - or will subtract in a calculation.&nbsp; <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction.&nbsp; In reality there is no such thing as negative... As to </P>
  • Bullet 2006-04-07 11:45
    Bullet:

    <P>
    Anonymous:
    Comment far above about velocity. Velocity is a vector quantity and can be negative. Speed is a scalar and cannot. <BR><BR>The only way I can think of that would make sense of this would be for fractions or some other strange numeric system that is treated as strings. Ex. If you wanted to store 1.5 as "1 1/2" what's written would be a better way of determining a negative number than doing the lookup to find the numeric value and arithmetic.
    </P>
    <P>&nbsp;</P>
    <P>Speed can be negative the same way that currency can be... When you are subtracting it... &nbsp; Negative currency means&nbsp;amounts that you owe someone, </P>
    <P>Negative speed means&nbsp;a chunk of speed that you "owe"&nbsp; - or will subtract in a calculation.&nbsp; <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction.&nbsp; In reality there is no such thing as negative... As to </P>
    <P>
    </P>
    <P>Sorry, accidently hit enter... <BR>Cont... As to Velocity, it is a misnomer to say it can be negative.&nbsp; No vector can be negative.&nbsp; A Vector is an ordered pair of scalars (actually any other objects, I guess), and only the constituent elements can be "negative".&nbsp; Taking the negative of a vector implies reversing the sign&nbsp;of all of it's constituent elements, some of which may be positive and some of which may be negative.&nbsp; Describing the vector as a whole as either positive or negative doesn't really make sense or have any meaning.&nbsp; The absolute value of a vector can be a scalar, but it of course is always positive. </P>
  • Diep 2006-04-07 12:00
    Bullet:
    Bullet:

    <P>
    Anonymous:
    Comment far above about velocity. Velocity is a vector quantity and can be negative. Speed is a scalar and cannot. <BR><BR>The only way I can think of that would make sense of this would be for fractions or some other strange numeric system that is treated as strings. Ex. If you wanted to store 1.5 as "1 1/2" what's written would be a better way of determining a negative number than doing the lookup to find the numeric value and arithmetic.
    </P>
    <P>&nbsp;</P>
    <P>Speed can be negative the same way that currency can be... When you are subtracting it... &nbsp; Negative currency means&nbsp;amounts that you owe someone, </P>
    <P>Negative speed means&nbsp;a chunk of speed that you "owe"&nbsp; - or will subtract in a calculation.&nbsp; <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction.&nbsp; In reality there is no such thing as negative... As to </P>
    <P>
    </P>
    <P>Sorry, accidently hit enter... <BR>Cont... As to Velocity, it is a misnomer to say it can be negative.&nbsp; No vector can be negative.&nbsp; A Vector is an ordered pair of scalars (actually any other objects, I guess), and only the constituent elements can be "negative".&nbsp; Taking the negative of a vector implies reversing the sign&nbsp;of all of it's constituent elements, some of which may be positive and some of which may be negative.&nbsp; Describing the vector as a whole as either positive or negative doesn't really make sense or have any meaning.&nbsp; The absolute value of a vector can be a scalar, but it of course is always positive. </P>
    <P>
    </P>
    <P>A 2D vector can be positive or negative. 3D vectors are a different story. However, scalars cannot be negative, since that would make them a vector.&nbsp;I guess.</P>
  • Bullet 2006-04-07 12:02
    <P>
    Anonymous:
    Wow. <BR><BR>I know the inevitable commentary will spring up about how the number is a double and might suffer from imprecision in comparisons. <BR><BR>--but that still doesn't justify _this_. <BR><BR>Wow.
    </P>
    <P>I don't believe there is any&nbsp;more intrinsic mprecision in floats / doubles than there is in integral values.&nbsp; The imprecision is just of a different kind.&nbsp; Both have the capability to exactly&nbsp;&nbsp;represent any one of&nbsp;a set of numbers.&nbsp; (2 to the N&nbsp; for an N-Bit variable).&nbsp; They are both&nbsp;absolutely accurate at representing the numbers they are designed to represent, and imprecise at representing any of the other&nbsp;numbers which lie between those on the number line.</P>
    <P>No Integer variable&nbsp;can represent 0.5 exactly&nbsp;&nbsp;.&nbsp; No decimal number can represent one third exactly, although it can represent &nbsp;.000001221 exactly.&nbsp; A IEEE float or double can represent any number which is a sum of positive and negative powers of 2 - exactly, with no imprecision.&nbsp; But that still leaves a gap between every adjacent pair of numbers... just like all the other schemes do.&nbsp; It's just that with floats and doubles, the integers end up in thoses gaps.&nbsp; </P>
    <P>And whatever the type of representation being used, integral, decimal, or foloat/double,&nbsp; zero can be represented exactly - there is never any imprecision for zero.&nbsp; </P>
    <P>&nbsp;</P>
  • Bullet 2006-04-07 12:10
    Anonymous:
    Bullet:
    Bullet:

    <P>
    Anonymous:
    Comment far above about velocity. Velocity is a vector quantity and can be negative. Speed is a scalar and cannot. <BR><BR>The only way I can think of that would make sense of this would be for fractions or some other strange numeric system that is treated as strings. Ex. If you wanted to store 1.5 as "1 1/2" what's written would be a better way of determining a negative number than doing the lookup to find the numeric value and arithmetic.
    </P>
    <P>&nbsp;</P>
    <P>Speed can be negative the same way that currency can be... When you are subtracting it... &nbsp; Negative currency means&nbsp;amounts that you owe someone, </P>
    <P>Negative speed means&nbsp;a chunk of speed that you "owe"&nbsp; - or will subtract in a calculation.&nbsp; <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction.&nbsp; In reality there is no such thing as negative... As to </P>
    <P>
    </P>
    <P>Sorry, accidently hit enter... <BR>Cont... As to Velocity, it is a misnomer to say it can be negative.&nbsp; No vector can be negative.&nbsp; A Vector is an ordered pair of scalars (actually any other objects, I guess), and only the constituent elements can be "negative".&nbsp; Taking the negative of a vector implies reversing the sign&nbsp;of all of it's constituent elements, some of which may be positive and some of which may be negative.&nbsp; Describing the vector as a whole as either positive or negative doesn't really make sense or have any meaning.&nbsp; The absolute value of a vector can be a scalar, but it of course is always positive. </P>
    <P>
    </P>
    <P>A 2D vector can be positive or negative. 3D vectors are a different story. However, scalars cannot be negative, since that would make them a vector.&nbsp;I guess.</P>
    <P>
    </P>
    <P>2D vectors cannot be positive / negative.&nbsp; No vector can be definitely evaluated as positive or negative.<BR>Here ar&nbsp;four 2D vectors... Which ones are positive, and which ones are negative?<BR>(2, -5)<BR>(-4, 8)<BR>(1, -3)<BR>(5, -7)</P>
  • Tyler 2006-04-07 13:33
    Bullet:
    <p>
    Anonymous:
    Wow. <br><br>I know the inevitable commentary will spring up about how the number is a double and might suffer from imprecision in comparisons. <br><br>--but that still doesn't justify _this_. <br><br>Wow.
    </p>
    <p>I don't believe there is any more intrinsic mprecision in floats / doubles than there is in integral values.  The imprecision is just of a different kind.  Both have the capability to exactly  represent any one of a set of numbers.  (2 to the N  for an N-Bit variable).  They are both absolutely accurate at representing the numbers they are designed to represent, and imprecise at representing any of the other numbers which lie between those on the number line.</p>
    <p>No Integer variable can represent 0.5 exactly  .  No decimal number can represent one third exactly, although it can represent  .000001221 exactly.  A IEEE float or double can represent any number which is a sum of positive and negative powers of 2 - exactly, with no imprecision.  But that still leaves a gap between every adjacent pair of numbers... just like all the other schemes do.  It's just that with floats and doubles, the integers end up in thoses gaps.  </p>
    <p>And whatever the type of representation being used, integral, decimal, or foloat/double,  zero can be represented exactly - there is never any imprecision for zero.  </p>
    <p> </p>
    <br>there is no imprecision in the floating point number 0.0 but there could be imprecision in how 0 was reached.  for instance.  what do you think the following program will output?   run it and you will notice 0 != 0 for sufficiently large (or small) values of 0.<br><br><span style="font-family: Courier New;">public static void main(String[] args) {<br>            double num = 1;<br>            for (int i = 0 ; i < 10; i++) {<br>                num -= (1.0/10.0);<br>            }<br>            if (num < 0) {<br>                System.out.println("Holy shit 0 is less than 0");<br>            }<br>            if (num > 0) {<br>                System.out.println("Holy shit 0 is more than 0");<br>            }<br>            if (num == 0) {<br>                System.out.println("Thank god 0 equals 0");<br>            }<br>        }</span><br><br>
  • Bullet 2006-04-07 14:34
    Anonymous:
    Bullet:

    <P>
    Anonymous:
    Wow. <BR><BR>I know the inevitable commentary will spring up about how the number is a double and might suffer from imprecision in comparisons. <BR><BR>--but that still doesn't justify _this_. <BR><BR>Wow.
    </P>
    <P>I don't believe there is any&nbsp;more intrinsic mprecision in floats / doubles than there is in integral values.&nbsp; The imprecision is just of a different kind.&nbsp; Both have the capability to exactly&nbsp;&nbsp;represent any one of&nbsp;a set of numbers.&nbsp; (2 to the N&nbsp; for an N-Bit variable).&nbsp; They are both&nbsp;absolutely accurate at representing the numbers they are designed to represent, and imprecise at representing any of the other&nbsp;numbers which lie between those on the number line.</P>
    <P>No Integer variable&nbsp;can represent 0.5 exactly&nbsp;&nbsp;.&nbsp; No decimal number can represent one third exactly, although it can represent &nbsp;.000001221 exactly.&nbsp; A IEEE float or double can represent any number which is a sum of positive and negative powers of 2 - exactly, with no imprecision.&nbsp; But that still leaves a gap between every adjacent pair of numbers... just like all the other schemes do.&nbsp; It's just that with floats and doubles, the integers end up in thoses gaps.&nbsp; </P>
    <P>And whatever the type of representation being used, integral, decimal, or foloat/double,&nbsp; zero can be represented exactly - there is never any imprecision for zero.&nbsp; </P>
    <P>&nbsp;</P>
    <P>
    <BR>there is no imprecision in the floating point number 0.0 but there could be imprecision in how 0 was reached.&nbsp; for instance.&nbsp; what do you think the following program will output?&nbsp;&nbsp; run it and you will notice 0 != 0 for sufficiently large (or small) values of 0.<BR><BR><SPAN style="FONT-FAMILY: Courier New">public static void main(String[] args) {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; double num = 1;<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (int i = 0 ; i &lt; 10; i++) {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; num -= (1.0/10.0);<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (num &lt; 0) {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("Holy shit 0 is less than 0");<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (num &gt; 0) {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("Holy shit 0 is more than 0");<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (num == 0) {<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; System.out.println("Thank god 0 equals 0");<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }</SPAN><BR><BR>
    </P>
    <P>&nbsp;</P>
    <P>I agree&nbsp;that the imprecision is not in zero, butI disagree that is in the process... Actually&nbsp;it is&nbsp;in the values of&nbsp; 0.1 through 1.0 that were used.&nbsp; those values cannot be represented <EM>exactly</EM> as a a IEEE double/float.&nbsp; This exactly analogous to the following, (in the opposite direction).</P><FONT size=2>
    <P></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> x = 0x034;<BR>d</FONT><FONT color=#0000ff size=2>ouble</FONT><FONT size=2> y1 = 0x0D0;<BR></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> z = 0x000008;<BR></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> ExactIncr = (x / y1); </FONT><FONT color=#008000 size=2>// Is exact cause it's power of 2<BR></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> total = z * ExactIncr;<BR></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2> (</FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> i = 0; i &lt; 8; i++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; total -= ExactIncr;<BR></FONT><FONT color=#008080 size=2>Console</FONT><FONT size=2>.WriteLine(</FONT><FONT color=#800000 size=2>"Total = {0}"</FONT><FONT size=2>, total); </FONT><FONT color=#008000 size=2>// Prints exactly zero<BR></FONT><FONT color=#008000 size=2>// --------------------------<BR></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> y2 = 0x0D3;<BR></FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> InExactIncr = (x / y2); </FONT><FONT color=#008000 size=2>// Is NOT exact cause not power of 2<BR></FONT><FONT size=2>total = z * InExactIncr;<BR></FONT><FONT color=#0000ff size=2>for</FONT><FONT size=2> (</FONT><FONT color=#0000ff size=2>int</FONT><FONT size=2> i = 0; i &lt; 8; i++)<BR>total -= InExactIncr;<BR></FONT><FONT color=#008080 size=2>Console</FONT><FONT size=2>.WriteLine(</FONT><FONT color=#800000 size=2>"Total = {0}"</FONT><FONT size=2>, total); </FONT><FONT color=#008000 size=2>// Prints slightly off zero... <BR></FONT><FONT color=#008000 size=2>// --------------------------<BR></FONT><FONT color=#008080 size=2>Console</FONT><FONT size=2>.Write(</FONT><FONT color=#800000 size=2>"Hit any key top exit"</FONT><FONT size=2>);<BR></FONT><FONT color=#008080 size=2>Console</FONT><FONT size=2>.ReadLine();</P></FONT>
    <P>&nbsp;</P>
  • Stephen 2006-06-22 23:44
    Anonymous:
    I know the inevitable commentary will spring up about how the number is a double and might suffer from imprecision in comparisons.
    <br><br>Won't happen. Signed floating point numbers have (duh), a sign bit. Simple as pie to test that bit, and thus determine whether or not the entire thing is negative, tiny as hell or not.<br>
  • Steeldragon 2006-06-26 10:41
    Bullet:
    Anonymous:
    Bullet:
    Bullet:

    <P>
    Anonymous:
    Comment far above about velocity. Velocity is a vector quantity and can be negative. Speed is a scalar and cannot. <BR><BR>The only way I can think of that would make sense of this would be for fractions or some other strange numeric system that is treated as strings. Ex. If you wanted to store 1.5 as "1 1/2" what's written would be a better way of determining a negative number than doing the lookup to find the numeric value and arithmetic.
    </P>
    <P>&nbsp;</P>
    <P>Speed can be negative the same way that currency can be... When you are subtracting it... &nbsp; Negative currency means&nbsp;amounts that you owe someone, </P>
    <P>Negative speed means&nbsp;a chunk of speed that you "owe"&nbsp; - or will subtract in a calculation.&nbsp; <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction.&nbsp; In reality there is no such thing as negative... As to </P>
    <P>
    </P>
    <P>Sorry, accidently hit enter... <BR>Cont... As to Velocity, it is a misnomer to say it can be negative.&nbsp; No vector can be negative.&nbsp; A Vector is an ordered pair of scalars (actually any other objects, I guess), and only the constituent elements can be "negative".&nbsp; Taking the negative of a vector implies reversing the sign&nbsp;of all of it's constituent elements, some of which may be positive and some of which may be negative.&nbsp; Describing the vector as a whole as either positive or negative doesn't really make sense or have any meaning.&nbsp; The absolute value of a vector can be a scalar, but it of course is always positive. </P>
    <P>
    </P>
    <P>A 2D vector can be positive or negative. 3D vectors are a different story. However, scalars cannot be negative, since that would make them a vector.&nbsp;I guess.</P>
    <P>
    </P>
    <P>2D vectors cannot be positive / negative.&nbsp; No vector can be definitely evaluated as positive or negative.<BR>Here ar&nbsp;four 2D vectors... Which ones are positive, and which ones are negative?<BR>(2, -5)<BR>(-4, 8)<BR>(1, -3)<BR>(5, -7)</P>
    <P>
    </P>
    <P>All of those are neither</P>
    <P>Heres Another</P>
    <P>(-1,-5) </P>
    <P>I think that ones negative overall though im not certain</P>
  • Emmanuel D. 2006-06-27 07:00
    Steeldragon:
    <p>All of those are neither</p>
    <p>Heres Another</p>
    <p>(-1,-5) </p>
    <p>I think that ones negative overall though im not certain</p>
    <br><br>There is no such thing as a negative vector - it doesn't make sense. Only reals (read: numbers in |R) can be negative. A number is negative if it is less than 0. Since there is no ordering in |R x |R (or any vector space except |R) you can't say that a vector is less than another vector, thus there is no negative vector (by extension). <br><br>And while I re-read the posts here, I see that despite the absolute, überstupidity of this WTF, people still try to find a valid reason for it. There is no valid reason for such kind of code, unless you really want to scare your coworkers. The real solution, however, imply using either IsTrue() or IsFalse() (maybe both) and perhaps the original author wanted to avoid it by using this ugly hack.<br><br>Regards, <br><br>E.<br>
  • mnature 2006-06-27 10:25
    Then there is the embedded programming approach.&nbsp; Figure out the largest positive number that will be encountered, and anything greater than that is a negative number.
  • csa 2006-08-22 09:23
    <P>I've thought about sending in a wtf for exactly this code!&nbsp; I had a programmer propose just such a method for determining a number is negative.&nbsp; Luckily we stopped that one before it got to code form.&nbsp; I can't believe there is more than one person that would come up with this 'solution'.</P>
  • fuulaluuf 2006-08-23 06:30
    <P>I dunno....</P>
    <P>I have&nbsp;a SQL Server 2005 table, with a Decimal column, with a ZERO value in the first row. </P>
    <P>When I export it to Excel, I get 0.0000000001</P>
    <P>Try as I might, I can't figure out the math.</P>
    <P>&nbsp;</P>
  • fuulaluuf 2006-08-23 06:33
    <P>.... let me clarify how the zero got there: the Default value&nbsp;of the column was 0. </P>
  • Someone out there 2009-05-18 05:08
    CornedBee:

    Somehow that makes me doubt the existence of this article.


    Maybe it was scheduled for the April edition, not August, but the underlying representation of the calendar was different.