| 03-18-2008, 08:56 PM | #1 |
Title says it all. Is H2I guaranteed to be positive / is it just always positive by luck / have you ever seen the output be negative? I ask because I'm taking the modulus of H2I a lot and if it's never negative I can cut out an operation. |
| 03-18-2008, 08:57 PM | #2 |
What do you mean by negative/positive? |
| 03-18-2008, 09:00 PM | #3 |
it's always positive, that's the handle "number" |
| 03-18-2008, 09:01 PM | #4 |
I think he means if it's a signed number. If you ever used a handle Id that exceeds the integer value limit then the integer value would be negative, but I think it's rare, so it's ok to do what you're trying to do. @Troll-Brain: It is always positive but the integer value that jass can handle is limited, I just don't know how much it can hold. so even if the handle Id is positive but it exceeds the limit it would be negative. Kinda like what happens to C. |
| 03-18-2008, 09:02 PM | #5 |
Well my answer is the same as Troll-Brain's. H2I will never return a negative value. I have never experienced it before. |
| 03-18-2008, 09:06 PM | #6 |
the max value is 2^31 -1 so have fun to reach it. you're the worst map maker on the world if you do it :p |
| 03-18-2008, 09:28 PM | #7 |
"code" handles seems to overflow 32 bit int :P (sometimes) well general "global" handles begin at 0x100000 => 1048576 so it's allmost immposible to reach 2 milliards ^^ (you would need 10+ GB of RAM xD for the simplest objects or much more...) so in general NO they can't be negative. |
| 03-18-2008, 09:34 PM | #8 |
good thing code data type are used rarely |
| 03-18-2008, 09:38 PM | #9 |
Well that answers my question. I was worried if someone had a lot of memory, and if handle indexes were memory addresses, that the representation would end up being interpreted as negative. |
| 03-18-2008, 09:39 PM | #10 | |
Quote:
only cause blizzard was lame and wouldn't allow it to be in an array. |
| 03-18-2008, 09:45 PM | #11 |
Ammorth +1 |
| 03-18-2008, 10:49 PM | #12 |
If code was allowed in an array it would still be totally useless. H2I does not always return possitive numbers, it may return 0 sometimes. |
| 03-18-2008, 10:52 PM | #13 | |
Quote:
Clever. lol. "Non-negative" Or I could be ambiguous and say "Natural" |
| 03-18-2008, 11:05 PM | #14 | |
Quote:
Then that makes function interfaces with non-taking non-returning functions useless, which it isn't. It would also allow one to stick code in structs which would be nice for physics systems and the like. |
| 03-18-2008, 11:18 PM | #15 | |
Quote:
You can H2I (actually Code2I) the code to an integer and store it that way. There's a few hickups converting it back to code, though. |
