Post #171,225
8/27/04 11:32:17 AM
|
Hex constants are assumed to be positive
0x80000000 would make an int to be negative, so it cannot be represented as int.
--
"...was poorly, lugubrious and intoxicated."
-- Patrick O'Brian, "Master and Commander"
|
Post #171,262
8/27/04 1:15:45 PM
|
Re: Hex constants are assumed to be positive
Sez who?
(OK, let me rephrase that with the smart-ass control turned down...Where in the ANSI standard does it say that hex constants are assumed to be positive?)
jb4 shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT
|
Post #171,268
8/27/04 1:27:28 PM
|
Setting the high bit is processor dependent.
It's not carved in stone anywhere that that's the only way to do it. Most do, but that's not specified generally anywhere.
|
Post #171,280
8/27/04 1:53:36 PM
|
OK, then the standard should be saying
"presentable in the implementation's architecture". What do you do with those nits, eat them?
--
"...was poorly, lugubrious and intoxicated."
-- Patrick O'Brian, "Master and Commander"
|
Post #171,304
8/27/04 2:27:25 PM
|
No I actually write code based on them
and then spend entirely too much time recovering from other's inability to use the English language effectively. What do you do with them?
jb4 shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT
|
Post #171,329
8/27/04 3:24:32 PM
|
Ignore them and use my common sence
--
"...was poorly, lugubrious and intoxicated."
-- Patrick O'Brian, "Master and Commander"
|
Post #171,752
8/30/04 5:29:56 PM
|
I'll bet debugging your code is a real joy...
;-)
jb4 shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT
|
Post #171,885
8/31/04 10:04:06 AM
|
Nope
The joy comes when you read your standard, forget your common sence and assume that same things work the same way everywhere.
--
"...was poorly, lugubrious and intoxicated."
-- Patrick O'Brian, "Master and Commander"
|
Post #171,899
8/31/04 11:04:10 AM
|
And so tell me, O Oracle of Common Sence [sic]
What exactly is it that is so nonsensical about defining a hex value and assuming it is treated as a signed value? We supplicate ourselves breathlessly at your feet awaiting such pearls (or is that perls) of wisdom as you may deign to proffer.
jb4 shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT
|
Post #171,902
8/31/04 11:10:45 AM
|
offensive foul, ball to Ark
You violated the "be kind to non-native English speakers" (who do extremely well in a totally different language and make us look stupid by comparison) rule.
Just point out that it's "sense".
BTW Ark - "licence" and "license" are both right. One is British. Likewise "offence" and "offense", "defence" and "defense". But "electric fense" is always wrong.
-drl
|
Post #171,909
8/31/04 11:17:52 AM
|
Rest assured,
I'd be making the same mistakes in Russian as well.
Por syntax checus in Cium - Deo Gratie.
--
"...was poorly, lugubrious and intoxicated."
-- Patrick O'Brian, "Master and Commander"
|
Post #171,913
8/31/04 11:25:55 AM
|
:) ok
-drl
|
Post #171,914
8/31/04 11:26:24 AM
8/31/04 11:26:59 AM
|
OK, OK...
I'll take my yellow card and give up an indirect free kick....
;-)
jb4 shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT
Edited by jb4
Aug. 31, 2004, 11:26:59 AM EDT
|
Post #171,904
8/31/04 11:14:05 AM
|
Well, while the tone is disagreable, the question is
(almost) legit \n#include <stdio.h>\n\n\nint main(int argc, char**argv) {\n int c = -0xFF;\n printf("signed: %d, hex: %X\\n", c, c);\n return 0;\n}\n \n$ gcc -o test test.c; ./test\nsigned: -255, hex: FFFFFF01\n And the answer is <drrrrum rrrroll>: The hex constants are treated as positive because they lack the "minus" in front. Tada!
--
"...was poorly, lugubrious and intoxicated."
-- Patrick O'Brian, "Master and Commander"
|
Post #171,912
8/31/04 11:25:35 AM
|
Point missed.
The point is not that I can generate a negative number using hex values, its that I can generate a specific bit pattern directly that is interpreted correctly using two's compliment arithmetic. In my example, I want the bit pattern 0x80000000. Interpreted as an int. Which is what I should expect, given that incomplete pile of verbage that passes as the C(99) standard in section 6.4.4.1, paragraph 5. Your example doesn't match, as you explicitly change the value of your bit pattern by applying an operator to it (the unary minus).
jb4 shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT
|
Post #171,915
8/31/04 11:26:40 AM
|
If C were sane, TRUE = -1 and problem vanishes
-drl
|
Post #171,917
8/31/04 11:28:42 AM
|
Ermm...say What?
You got me on that one, Ross. How does the value of a boolean have anything to do with how a constant token is interpreted?
jb4 shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT
|
Post #171,924
8/31/04 11:37:26 AM
|
Re: Ermm...say What?
It forces strict attention to signed vs. unsigned, because TRUE is signed.
IOW we don't need no steenkin Booleans.
-drl
|
Post #171,929
8/31/04 11:43:34 AM
|
Much like Jewish law
Forces strict attention to matters divine because it's so easy to transgress. Any takers?
You recommend a practice because it's easy to violate? Ouch.
--
"...was poorly, lugubrious and intoxicated."
-- Patrick O'Brian, "Master and Commander"
|
Post #171,961
8/31/04 1:01:31 PM
|
So you prefer how VB does it??
To deny the indirect purchaser, who in this case is the ultimate purchaser, the right to seek relief from unlawful conduct, would essentially remove the word consumer from the Consumer Protection Act - [link|http://www.techworld.com/opsys/news/index.cfm?NewsID=1246&Page=1&pagePos=20|Nebraska Supreme Court]
|
Post #171,962
8/31/04 1:04:18 PM
|
Point: Ben...
jb4 shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT
|
Post #171,972
8/31/04 1:47:19 PM
|
How it used to do it.
VB.Net had to play a little nicer with the other languages, so they switched to the way it's represented in C#.
|
Post #171,991
8/31/04 3:18:32 PM
|
Hehee!
VB was "embraced and extended" by C! Oh, the irony!
jb4 shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT
|
Post #171,921
8/31/04 11:31:50 AM
8/31/04 11:32:44 AM
|
Why do you expect hex to be treated differently from decimal
?
When you see a decimal constant 4294967294, do you expect it to mean -2?
--
"...was poorly, lugubrious and intoxicated."
-- Patrick O'Brian, "Master and Commander"
Edited by Arkadiy
Aug. 31, 2004, 11:32:44 AM EDT
|
Post #171,926
8/31/04 11:42:16 AM
|
Re: Why do you expect hex to be treated differently
In FORTH this issue never arises. An integer is what it is in relation to base 2 and the number of available bits in it. Signed vs. unsigned is a stupid, needless complication.
So: TRUE is 111111...1 and FALSE is 000000...0. There is only one TRUE and one FALSE and NOT TRUE is FALSE. Something like 1101001..1 has no logical value.
The programmatic representation is immaterial.
-drl
|
Post #171,953
8/31/04 12:37:46 PM
|
Man, that's a good question!
I suppose because I can specify a bit pattern directly, and I expected that bit pattern to be interpreted by the underlying hardware directly. But I must say, I now see your point, and it is a good one.
Thanx!
jb4 shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT
|
Post #172,013
8/31/04 4:42:17 PM
|
Now that's clarity!
Alex
"If you can control the meaning of words, you can control the people who must use the words." -- Philip K. Dick, US science fiction writer
|
Post #172,017
8/31/04 5:00:03 PM
|
Nope, it's bad math
A 32 bit integer has 4...mumble possible values. If you really want integers and not whole numbers, then implicitly these are signed, which requires a bit. So there are 2...mumble positive values, 2...mumble-1 negative values, and zero.
If you want 4...mumble integers you need more bits.
-drl
|
Post #172,022
8/31/04 5:19:13 PM
|
But, counters of real things don't need negative values.
Alex
"If you can control the meaning of words, you can control the people who must use the words." -- Philip K. Dick, US science fiction writer
|
Post #172,023
8/31/04 5:20:08 PM
|
I'd like to add a negative number of votes for Bush. ;-)
To deny the indirect purchaser, who in this case is the ultimate purchaser, the right to seek relief from unlawful conduct, would essentially remove the word consumer from the Consumer Protection Act - [link|http://www.techworld.com/opsys/news/index.cfm?NewsID=1246&Page=1&pagePos=20|Nebraska Supreme Court]
|
Post #172,025
8/31/04 5:23:34 PM
|
That only works on Diebold machines. :)
Alex
"If you can control the meaning of words, you can control the people who must use the words." -- Philip K. Dick, US science fiction writer
|
Post #172,024
8/31/04 5:21:51 PM
|
Certainly
But then, Ark's comment loses its pithiness (\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd)
-drl
|
Post #172,046
8/31/04 6:59:29 PM
|
"Expressive", not "pithy" :)
"pithy" I guess would be better translated as poisonous, ядовитый - it's an idiomatic usage.
--
"...was poorly, lugubrious and intoxicated."
-- Patrick O'Brian, "Master and Commander"
|
Post #172,047
8/31/04 7:03:32 PM
|
Re: "Expressive", not "pithy" :)
Why can I see your Cyrillic but not mine? Some encoding mojo?
-drl
|
Post #172,172
9/1/04 9:33:56 AM
|
Dunno.
I see yours fine in Mozilla on Win 2000 after I select the proper code page - Cyrillic Windows-1251
--
"...was poorly, lugubrious and intoxicated."
-- Patrick O'Brian, "Master and Commander"
|
Post #171,339
8/27/04 4:06:40 PM
|
Wasn't trying to piss you off...
From my point of view, hex and octal are just more convienient ways to write binary. Hex/octal/binary numbers are not negative without some convention to make them so. This varies. The C language, and those that borrowed from it, make the tacit assumption that the high bit indicates a negative number unless it is declared unsigned, in which case it is just a binary number in the range of 0 - UINT_MAX (from limits.h) I don't know of any languages where you can write -0x123 for a negative hex number. I should mention that I am not particularly a language pedant. I currently use C/C++ for some application work and drivers, I write firmware for a propriatary processor in a much modified, self maintained assembler, and do scripting in perl as necessary. Plus whatever needs be done. I'm not a purist. I really wasn't trying to pick nits.
|
Post #171,760
8/30/04 5:51:55 PM
|
Interesting assumption:
The C language, and those that borrowed from it, make the tacit assumption that the high bit indicates a negative number unless it is declared unsigned... An interesting assumption. I don't believe C makes that assumption at all. The underlying hardware makes that assumption, because that's simply the way it works. C (the language) doesn't care. An implementation of C cares, because it has to map tokens that represent negative values to the actual binary representation of the value. Now it has been several Decades since I saw a machine that doesn't uset two's complement arithmetic. The first one was an NCR 315 that our local bank used when I was in high school in 1968...It was a DECIMAL machine that used XS-3 notation internally. the last one I saw was a CDC Star, which is a 60-bit (!) machine that used ones complement artihmetic...which has a unique value for negative zero. The NCR machine antedated C by something like a decade, but were a C compiler to exist for that machine, it could not assume the high-order bit of a value made it negative.
jb4 shrub\ufffdbish (Am., from shrub + rubbish, after the derisive name for America's 43 president; 2003) n. 1. a form of nonsensical political doubletalk wherein the speaker attempts to defend the indefensible by lying, obfuscation, or otherwise misstating the facts; GIBBERISH. 2. any of a collection of utterances from America's putative 43rd president. cf. BULLSHIT
|