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.

Jack2004-10-07 13:57

And people question the fact that good programmers can easily outperform the bad ones by a factor of 5

xellos2004-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.

ifdef2004-10-07 14:07

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 < atoi("10"))
<br>
<br>This mechanism gives you maximum portability..."
<br>
<br>:)

Chris R. Timmons2004-10-07 14:12

What language was this written in? It's kind of hard to tell when a "C"-like code snippet is posted. It almost looks like C#, except the line "string nStr = n.ToString" isn't valid C# code (missing the () after ToString), and the nStr variable is referenced as nstr (note the lowercase "s").

mrd2004-10-07 14:19

Is -0.0 less than 0.0?

Dave Mays2004-10-07 14:23

I would guess it's badly transcribed C#.

Alex Papadimoulis2004-10-07 14:28

It's a strange error that occurs in the Screenshot->Text routine I use. It would seem that there are occasional typos.
<br>
<br>:-D

Phil Scott2004-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 "negative symbol" appears to the right of the digits in some cultures. What these cultures are, well, I have no clue.

Christian Duhard2004-10-07 14:28

No idea what language this code is.
<br>
<br>If it's legitimate, wow.

Christian Duhard2004-10-07 14:30

Looks like the transcribed code ahas been fixed .. It's bad C# now.

Dave Mays2004-10-07 14:36

while(nstr != nStr)
<br>{
<br>//noop
<br>}

WanFactory2004-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

chandler2004-10-07 14:58

Does Java have -0.0? If so, what is the result of comparing that via d < 0?

Guayo2004-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("Dude!... You are moving backwards!");
<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>}

JeffS2004-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 "1.0E-17" -- which this method would interpret as being a negative number since it contains a "-" symbol at any position.

Guayo2004-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.

andrei2004-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 S2004-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>"-" 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>

WanFactory2004-10-07 16:04

Aha! I found out why n < 0 won't do...
<br>
<br>if n is negative infinity, n < 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...

Guayo2004-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 <0? (Now it seems that it's just the opposite)
<br>Does –0 < +0? (my brains hurts by now)...
<br>I think I just walk away and get some fresh air.

Wojo2004-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? :-)

Guayo2004-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#.

Guayo2004-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. ;-)

Wojo2004-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 Voyeau2004-10-07 17:33

Assuming this is C#, why not just use the Sign function in the Math class???

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'blomi2004-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>}

Zka2004-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 :]

Zka2004-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>

Zka2004-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...

Sam2004-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 S2004-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 "WTF?".ToBoolean()
<br>End Select
<br>End Function

foxyshadis2004-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 Bellingham2004-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.

Zka2004-10-08 06:57

Sam: i do :) But i tried to create a more f*cked-up version :)

Tony2004-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 "(n<0) won't do":
<br>
<br>public class Foo {
<br> public static void main(String... args) {
<br> double d = -0d;
<br> // Displays "false", NOT "true".
<br> System.out.println(d < 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 Papadimoulis2004-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 ;-)

nobody2004-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. <a href=<a target="_new" href="http://www.jaggersoft.com/csharp_standard/11.1.5.htm>reference">http://www.jaggersoft.com/csharp_standard/11.1.5.htm>reference</a> here</a>

@nobody
<br>It's not C# because nstr.IndexOf('-', 0, 1)) does not returns a boolean value... it could be JScript.Net

Guayo2004-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 Papadimoulis2004-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 "==0". 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 S2004-10-08 13:38

So that explains it. The "==0" is critical to this function, as it is written!
<br>
<br>Because as I mentioned, without the "==0", the function returns the OPPOSITE of what it says it does.

Miles Archer2004-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 "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.

me2004-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

fluffy2004-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 < 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 "because they can."

andrei2004-10-11 10:25

> That assumes that 0 != -0.0
<br>
<br>Bad assumption, fluffy

init62004-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 "double" 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.

ML2004-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.

SR2004-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 < 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.

mikeblas2004-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

jw2004-11-04 09:49

SR, floating point numbers != real numbers. (negative(r) <-> r<0) =/=> (negative(fp) <-> fp<0)
<br>
<br>Hmmkay? </nit>

Katja Bergman2005-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>

yawmark2005-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>

JJ2005-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> </P>

Schol-R-LEA2005-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>

CornedBee2005-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 < 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>

jspenguin2006-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>

Fireblaze2006-01-29 17:29

A factor 10, according to Facts and Fallacies of Software Engineering by Robert L. Glass

"Something didn't quite work out ... "
"- CAPTCHA Validation Incorrect"... WTF? LOL ;)

ObySamKenoby2006-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 > -0.0<br><br>OK, I'm already calling the asylum.:D<br><br>Samuele<br>

Loren Pechtel2006-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>

Ulvhamne2006-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 < 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>

</P>
<P>OH!</P>
<P>Now that I quoted it. The code makes sense. Before, you couldnt see the " 'less than' X + 1 GOTO 20" part of it. ;) Makes sense now that there is some kind of loop there .;)</P>

Pasa2006-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 Ober2006-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 :)

mnebuerquo2006-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>

Tangurena2006-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>

Bullet2006-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> </P>
<P>Speed can be negative the same way that currency can be... When you are subtracting it... Negative currency means amounts that you owe someone, </P>
<P>Negative speed means a chunk of speed that you "owe" - or will subtract in a calculation. <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction. In reality there is no such thing as negative... As </P>

Bullet2006-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> </P>
<P>Speed can be negative the same way that currency can be... When you are subtracting it... Negative currency means amounts that you owe someone, </P>
<P>Negative speed means a chunk of speed that you "owe" - or will subtract in a calculation. <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction. In reality there is no such thing as negative... As to </P>

Bullet2006-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> </P>
<P>Speed can be negative the same way that currency can be... When you are subtracting it... Negative currency means amounts that you owe someone, </P>
<P>Negative speed means a chunk of speed that you "owe" - or will subtract in a calculation. <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction. 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. No vector can be negative. A Vector is an ordered pair of scalars (actually any other objects, I guess), and only the constituent elements can be "negative". Taking the negative of a vector implies reversing the sign of all of it's constituent elements, some of which may be positive and some of which may be negative. Describing the vector as a whole as either positive or negative doesn't really make sense or have any meaning. The absolute value of a vector can be a scalar, but it of course is always positive. </P>

Diep2006-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> </P>
<P>Speed can be negative the same way that currency can be... When you are subtracting it... Negative currency means amounts that you owe someone, </P>
<P>Negative speed means a chunk of speed that you "owe" - or will subtract in a calculation. <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction. 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. No vector can be negative. A Vector is an ordered pair of scalars (actually any other objects, I guess), and only the constituent elements can be "negative". Taking the negative of a vector implies reversing the sign of all of it's constituent elements, some of which may be positive and some of which may be negative. Describing the vector as a whole as either positive or negative doesn't really make sense or have any meaning. 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. I guess.</P>

Bullet2006-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 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>

Bullet2006-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> </P>
<P>Speed can be negative the same way that currency can be... When you are subtracting it... Negative currency means amounts that you owe someone, </P>
<P>Negative speed means a chunk of speed that you "owe" - or will subtract in a calculation. <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction. 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. No vector can be negative. A Vector is an ordered pair of scalars (actually any other objects, I guess), and only the constituent elements can be "negative". Taking the negative of a vector implies reversing the sign of all of it's constituent elements, some of which may be positive and some of which may be negative. Describing the vector as a whole as either positive or negative doesn't really make sense or have any meaning. 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. I guess.</P>
<P>

</P>
<P>2D vectors cannot be positive / negative. No vector can be definitely evaluated as positive or negative.<BR>Here ar 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>

Tyler2006-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>

Bullet2006-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 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>
<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>

</P>
<P> </P>
<P>I agree that the imprecision is not in zero, butI disagree that is in the process... Actually it is in the values of 0.1 through 1.0 that were used. those values cannot be represented <EM>exactly</EM> as a a IEEE double/float. 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 < 8; i++)<BR> 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 < 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> </P>

Stephen2006-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>

Steeldragon2006-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> </P>
<P>Speed can be negative the same way that currency can be... When you are subtracting it... Negative currency means amounts that you owe someone, </P>
<P>Negative speed means a chunk of speed that you "owe" - or will subtract in a calculation. <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction. 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. No vector can be negative. A Vector is an ordered pair of scalars (actually any other objects, I guess), and only the constituent elements can be "negative". Taking the negative of a vector implies reversing the sign of all of it's constituent elements, some of which may be positive and some of which may be negative. Describing the vector as a whole as either positive or negative doesn't really make sense or have any meaning. 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. I guess.</P>
<P>

</P>
<P>2D vectors cannot be positive / negative. No vector can be definitely evaluated as positive or negative.<BR>Here ar 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>

mnature2006-06-27 10:25

Then there is the embedded programming approach. Figure out the largest positive number that will be encountered, and anything greater than that is a negative number.

csa2006-08-22 09:23

<P>I've thought about sending in a wtf for exactly this code! I had a programmer propose just such a method for determining a number is negative. Luckily we stopped that one before it got to code form. I can't believe there is more than one person that would come up with this 'solution'.</P>

fuulaluuf2006-08-23 06:30

<P>I dunno....</P>
<P>I have 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> </P>

fuulaluuf2006-08-23 06:33

<P>.... let me clarify how the zero got there: the Default value of the column was 0. </P>

Someone out there2009-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.

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>

Funny, that's exactly why I avoided that major. Ah, well; we live, we learn.... :)<br>

<br>

<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> </P>

</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>

<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>

<pre>public boolean isNegative(double d) {

long l = Double.doubleToLongBits(d);

if (l&0x8000000000000000L) return true;

return false;

}</pre>

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 ;)

<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 > -0.0<br><br>OK, I'm already calling the asylum.:D<br><br>Samuele<br>

<P>OH!</P>

<P>Now that I quoted it. The code makes sense. Before, you couldnt see the " 'less than' X + 1 GOTO 20" part of it. ;) Makes sense now that there is some kind of loop there .;)</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>

<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>

<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>

<P> </P>

<P>Speed can be negative the same way that currency can be... When you are subtracting it... Negative currency means amounts that you owe someone, </P>

<P>Negative speed means a chunk of speed that you "owe" - or will subtract in a calculation. <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction. In reality there is no such thing as negative... As </P>

<P> </P>

<P>Speed can be negative the same way that currency can be... When you are subtracting it... Negative currency means amounts that you owe someone, </P>

<P>Negative speed means a chunk of speed that you "owe" - or will subtract in a calculation. <BR>On a more philosophical note, that's what ALL negative numbers mean... They are just shortcut symbology to represent subtraction. In reality there is no such thing as negative... As to </P>

<P>Sorry, accidently hit enter... <BR>Cont... As to Velocity, it is a misnomer to say it can be negative. No vector can be negative. A Vector is an ordered pair of scalars (actually any other objects, I guess), and only the constituent elements can be "negative". Taking the negative of a vector implies reversing the sign of all of it's constituent elements, some of which may be positive and some of which may be negative. Describing the vector as a whole as either positive or negative doesn't really make sense or have any meaning. The absolute value of a vector can be a scalar, but it of course is always positive. </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. I guess.</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>

<P>2D vectors cannot be positive / negative. No vector can be definitely evaluated as positive or negative.<BR>Here ar 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>I agree that the imprecision is not in zero, butI disagree that is in the process... Actually it is in the values of 0.1 through 1.0 that were used. those values cannot be represented <EM>exactly</EM> as a a IEEE double/float. 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 < 8; i++)<BR> 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 < 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> </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>

<P>I have 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> </P>

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