• andrei (unregistered)

    > That assumes that 0 != -0.0

    Bad assumption, fluffy

  • init6 (unregistered)

    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.

    I've maintained code for years and I have seen some bad code but this, Oh Sh*t it's probably real code. scream

    I'm going to go try to think up some way to profit from all the stupidity on this planet. Good day all.

  • ML (unregistered)

    Why not simply converting the double value to binary then to string and checking whether the first character is a '1'?

    LOL

  • Stephen Holland, M.D. (unregistered)

    The one's complement of -1 is 11111110 on an 8 bit machine.

  • SR (unregistered)

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

  • mikeblas (unregistered)

    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.

    Or, that I used to keep there, anyay. It got emptied.

    .B ekiM

  • jw (unregistered)

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

    Hmmkay? </nit>

  • (cs)

    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-"...
    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. [;)]

  • (cs)
    I must say, I do appreciate the irony that many students shy away from Computer Science because they fear the complicated math.

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

  • JJ (unregistered) in reply to foobar

    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>

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

     

  • (cs) in reply to JJ
    Anonymous:

    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>

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


    You should have told them 'yes'. It's BS, of course, but at least they would have learned not to use globals. ;)

  • (cs) in reply to ifdef
    Anonymous:
    Ken Arnold wrote this in August 1989 Unix Review and I quote:

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

    Generally speaking, you cannot rely upon the underlying representation of even integers...

    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

    i += atoi("1");.

    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,

    if (count < atoi("10"))

    This mechanism gives you maximum portability..."

    :)


    Curious. Many things about this.
    First, 1's complement representation of -1 is 11111110, not 10000001. That would be Sign Bit representation.
    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.

    Somehow that makes me doubt the existence of this article.
  • jspenguin (unregistered) in reply to CornedBee

    In Java you can do this:

    public boolean isNegative(double d) {
        long l = Double.doubleToLongBits(d);
        if (l&0x8000000000000000L) return true;
        return false;
    }
  • Fireblaze (unregistered) in reply to Jack

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

  • (cs) in reply to mrd
    Anonymous:
    Is -0.0 less than 0.0?


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

    So we have:
    0+ = +0.00000..... . . . .....0001
    0- = -0.00000..... . . . .....0001

    If you consider only the first decimal (keeping the value) you have

    0+ = +0.0
    0- = -0.0

    So 0.0 > -0.0

    OK, I'm already calling the asylum.:D

    Samuele
  • Loren Pechtel (unregistered) in reply to Dave Mays
    Anonymous:
    while(nstr != nStr)
    {
    //noop
    }


    Well, many, many moons ago I wrote a short program and shook up every teacher in the department.

    10 X = 3000000
    20 X = X + 1
    30 IF X < X + 1 GOTO 20
    40 PRINT X

    *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.)

    (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.)
  • (cs) in reply to Loren Pechtel

    Anonymous:

    Well, many, many moons ago I wrote a short program and shook up every teacher in the department.

    10 X = 3000000
    20 X = X + 1
    30 IF X < X + 1 GOTO 20
    40 PRINT X

    *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.)

    (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.)

    OH!

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

  • Pasa (unregistered) in reply to ifdef

    Anonymous:
    Ken Arnold wrote this in August 1989 Unix Review and I quote:

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

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

  • Kuba Ober (unregistered) in reply to mrd

    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 (unregistered) in reply to ifdef

    Anonymous:
    Ken Arnold wrote this in August 1989 Unix Review and I quote:
    ...

    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
    i += atoi("1");.

    ...

    This mechanism gives you maximum portability..."

    :)

    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.

    Thanks

  • (cs) in reply to mnebuerquo

    There is an old COBOL technique called "overpunched signed fields."

    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.

  • (cs) in reply to Miles Archer

    Anonymous:
    Comment far above about velocity. Velocity is a vector quantity and can be negative. Speed is a scalar and cannot.

    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.

     

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

    Negative speed means a chunk of speed that you "owe"  - or will subtract in a calculation. 
    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

  • (cs) in reply to Miles Archer

    Anonymous:
    Comment far above about velocity. Velocity is a vector quantity and can be negative. Speed is a scalar and cannot.

    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.

     

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

    Negative speed means a chunk of speed that you "owe"  - or will subtract in a calculation. 
    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

  • (cs) in reply to Bullet
    Bullet:

    Anonymous:
    Comment far above about velocity. Velocity is a vector quantity and can be negative. Speed is a scalar and cannot.

    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.

     

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

    Negative speed means a chunk of speed that you "owe"  - or will subtract in a calculation. 
    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

    Sorry, accidently hit enter...
    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.

  • Diep (unregistered) in reply to Bullet
    Bullet:
    Bullet:

    Anonymous:
    Comment far above about velocity. Velocity is a vector quantity and can be negative. Speed is a scalar and cannot.

    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.

     

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

    Negative speed means a chunk of speed that you "owe"  - or will subtract in a calculation. 
    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

    Sorry, accidently hit enter...
    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.

    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.

  • (cs) in reply to foobar

    Anonymous:
    Wow.

    I know the inevitable commentary will spring up about how the number is a double and might suffer from imprecision in comparisons.

    --but that still doesn't justify _this_.

    Wow.

    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.

    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. 

    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. 

     

  • (cs) in reply to Diep
    Anonymous:
    Bullet:
    Bullet:

    Anonymous:
    Comment far above about velocity. Velocity is a vector quantity and can be negative. Speed is a scalar and cannot.

    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.

     

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

    Negative speed means a chunk of speed that you "owe"  - or will subtract in a calculation. 
    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

    Sorry, accidently hit enter...
    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.

    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.

    2D vectors cannot be positive / negative.  No vector can be definitely evaluated as positive or negative.
    Here ar four 2D vectors... Which ones are positive, and which ones are negative?
    (2, -5)
    (-4, 8)
    (1, -3)
    (5, -7)

  • Tyler (unregistered) in reply to Bullet
    Bullet:

    Anonymous:
    Wow.

    I know the inevitable commentary will spring up about how the number is a double and might suffer from imprecision in comparisons.

    --but that still doesn't justify _this_.

    Wow.

    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.

    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. 

    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. 

     


    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.

    public static void main(String[] args) {
                double num = 1;
                for (int i = 0 ; i < 10; i++) {
                    num -= (1.0/10.0);
                }
                if (num < 0) {
                    System.out.println("Holy shit 0 is less than 0");
                }
                if (num > 0) {
                    System.out.println("Holy shit 0 is more than 0");
                }
                if (num == 0) {
                    System.out.println("Thank god 0 equals 0");
                }
            }


  • (cs) in reply to Tyler
    Anonymous:
    Bullet:

    Anonymous:
    Wow.

    I know the inevitable commentary will spring up about how the number is a double and might suffer from imprecision in comparisons.

    --but that still doesn't justify _this_.

    Wow.

    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.

    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. 

    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. 

     


    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.

    public static void main(String[] args) {
                double num = 1;
                for (int i = 0 ; i < 10; i++) {
                    num -= (1.0/10.0);
                }
                if (num < 0) {
                    System.out.println("Holy shit 0 is less than 0");
                }
                if (num > 0) {
                    System.out.println("Holy shit 0 is more than 0");
                }
                if (num == 0) {
                    System.out.println("Thank god 0 equals 0");
                }
            }


     

    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 exactly as a a IEEE double/float.  This exactly analogous to the following, (in the opposite direction).

    <FONT size=2>

    </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> x = 0x034;
    d</FONT><FONT color=#0000ff size=2>ouble</FONT><FONT size=2> y1 = 0x0D0;
    </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> z = 0x000008;
    </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
    </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> total = z * ExactIncr;
    </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++)
              total -= ExactIncr;
    </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
    </FONT><FONT color=#008000 size=2>// --------------------------
    </FONT><FONT color=#0000ff size=2>double</FONT><FONT size=2> y2 = 0x0D3;
    </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
    </FONT><FONT size=2>total = z * InExactIncr;
    </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++)
    total -= InExactIncr;
    </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...
    </FONT><FONT color=#008000 size=2>// --------------------------
    </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>);
    </FONT><FONT color=#008080 size=2>Console</FONT><FONT size=2>.ReadLine();

    </FONT>

     

  • Stephen (unregistered) in reply to foobar
    Anonymous:
    I know the inevitable commentary will spring up about how the number is a double and might suffer from imprecision in comparisons.


    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.
  • (cs) in reply to Bullet
    Bullet:
    Anonymous:
    Bullet:
    Bullet:

    Anonymous:
    Comment far above about velocity. Velocity is a vector quantity and can be negative. Speed is a scalar and cannot.

    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.

     

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

    Negative speed means a chunk of speed that you "owe"  - or will subtract in a calculation. 
    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

    Sorry, accidently hit enter...
    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.

    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.

    2D vectors cannot be positive / negative.  No vector can be definitely evaluated as positive or negative.
    Here ar four 2D vectors... Which ones are positive, and which ones are negative?
    (2, -5)
    (-4, 8)
    (1, -3)
    (5, -7)

    All of those are neither

    Heres Another

    (-1,-5)

    I think that ones negative overall though im not certain

  • Emmanuel D. (unregistered) in reply to Steeldragon
    Steeldragon:

    All of those are neither

    Heres Another

    (-1,-5)

    I think that ones negative overall though im not certain



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

    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.

    Regards,

    E.
  • (cs)

    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.

  • csa (unregistered)

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

  • fuulaluuf (unregistered) in reply to xellos

    I dunno....

    I have a SQL Server 2005 table, with a Decimal column, with a ZERO value in the first row.

    When I export it to Excel, I get 0.0000000001

    Try as I might, I can't figure out the math.

     

  • fuulaluuf (unregistered) in reply to fuulaluuf

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

  • Someone out there (unregistered) in reply to CornedBee
    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.

Leave a comment on “When (n<0) won't do.”

Log In or post as a guest

Replying to comment #:

« Return to Article