Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Correct Behaviour? Was False = 2 ????

From: joel:neely:fedex at: 4-Jul-2001 5:27

Hi, Ken, Ken Anthony wrote:
> ... I say we give the minority a chance here. So lets all > quiet down and give those folks that want to start indexing > with some number *other* than one or zero a chance to speak! > > Anyone from the seven crowd have anything to say? >
I had considered earlier mentioning that in Pascal (and ADA, IIRC), one is allowed to specify for each array the bounds of its subscripts. This can be highly useful in some settings. As a fairly trivial example, imagine reading a file containing data on junior-high and high-school students and tallying the number of students in each grade. (With apologies to our friends around the world, I'll stick with the US conventions with which I'm familiar!) Since those grades are numbered 7 through 12, it would be handy to be able to create an array containing only those indices, to avoid wasting space and performing explicit grade-to-index translation in my code. Ooops! That example actually started with seven! ;-)
> Does anybody know of a use for negative zero? >
IIRC the computers made by CDC back in the 60's and 70's used 1's-complement arithmetic instead of 2's-complement, which meant that negative zero was actually a possibility. This allowed for some interesting and subtle bugs, as witnessed by the fact that RFC 1624, "Computation of the Internet Checksum via Incremental Update" (May 1994), specifically stated A historical aside: the fact that standard one's complement arithmetic produces negative zero results is one of its main drawbacks; it makes for difficulty in interpretation. In the CDC 6000 series computers [4], this problem was avoided by using subtraction as the primitive in one's complement arithmetic (i.e., addition is subtraction of the complement). Apparently the current IEEE standard allows it as well. As for uses... 1) Since it is logically superflouous, one could use -0 as an indication of "no answer", provided one insured that no other computation (e.g., -1 * (1 - 1)) could produce -0 as a result. HEY!!! true = 1 false = 0 none = -1 NONONONO! (only kidding! ;-) 2) It appears to be a way to crash a Microsoft database! ;-) "If a SQL Server query returns a negative zero, and the client application binds the results as a SQL_C_DOUBLE, the following error is reported to the client: [Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification ... SQL Server is returning a negative zero, and the SQL Server driver is reporting this as an error. To reproduce the error run the following query: SELECT 0.0 * -1 ... Microsoft has confirmed this to be a problem in SQL Server 7.0." -jn- ------------------------------------------------------------ Programming languages: compact, powerful, simple ... Pick any two! joel'dot'neely'at'fedex'dot'com