Staredit Network > Forums > SC1 UMS Mapmaking Assistance > Topic: Death counters are signed???
Death counters are signed???
Nov 15 2009, 8:13 pm
By: scwizard  

Nov 16 2009, 11:49 pm rockz Post #21

ᴄʜᴇᴇsᴇ ɪᴛ!

There's not much problem IMO.

Subtract has a built in limiter which, when you subtract a number which would push it under 0, it will set to 0.

Code
Trigger("Player 1"){
Conditions:
   Always();

Actions:
   Set Deaths("Current Player", "Goliath Turret", Set To, 5);
   Set Deaths("Current Player", "Goliath Turret", Subtract, -3);
}

This is 0x00000005 - 0xFFFFFFFD = 0

Now try (-1) - (-100) = 99.
This is 0xFFFFFFFF - 0xFFFFFF9C = 0x00000063 = 99

You can't write outside the 4 bytes allocated to the data, so 0xFFFFFFFF + 1 = 0, not 0x01 00 00 00 00. I agree with nude that there are no overflows. Any "overflow" is blocked somehow, but you can always loop back.

In conditions, -1 > 1.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Nov 17 2009, 9:49 am Wormer Post #22



Probably I've mixed up the term "overflow" meaning.
What I call overflow is 0xFFFFFFFF + 1 = 0.
When I say there is no overflow it is 0xFFFFFFFF + 1 = 0xFFFFFFFF.



Some.

Nov 17 2009, 4:52 pm rockz Post #23

ᴄʜᴇᴇsᴇ ɪᴛ!

Then yes, I agree. There is no overflow on subtraction. There is overflow on addition.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Nov 17 2009, 9:10 pm Wormer Post #24



The more I think about it the more I come to the conclusion scwizard is right.

In my opinion,
we should state DCs are unsigned except for the addition operation, which yields overflows.

So technically one could implement signed DCs using only addition and negative integers encoding with higher integers, but on the triggers level they are still handled as unsigned.



Some.

Nov 17 2009, 11:59 pm Falkoner Post #25



I wouldn't really call it an overflow, I usually think of an overflow as when the modification happens further in memory than the variable itself, but this is contained inside the variable.



None.

Nov 18 2009, 1:49 am rockz Post #26

ᴄʜᴇᴇsᴇ ɪᴛ!

Quote from wikipedia
In computer security and programming, a buffer overflow, or buffer overrun, is an anomaly where a process stores data in a buffer outside the memory the programmer set aside for it. The extra data overwrites adjacent memory, which may contain other data, including program variables and program flow control data
Quote from wikipedia
The term arithmetic overflow or simply overflow has the following meanings.
1. In a computer, the condition that occurs when a calculation produces a result that is greater in magnitude than that which a given register or storage location can store or represent.
2. In a computer, the amount by which a calculated value is greater than that which a given register or storage location can store or represent. Note that the overflow may be placed at another location.
A buffer overflow writes, an arithmetic overflow doesn't necessarily, but that's all semantics.

It's easier to say conditions are unsigned, and subtraction is unsigned and won't overflow, whereas addition is signed and overflow is possible.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Nov 18 2009, 5:46 pm NudeRaider Post #27

We can't explain the universe, just describe it; and we don't know whether our theories are true, we just know they're not wrong. >Harald Lesch

Quote from rockz
It's easier to say conditions are unsigned, and subtraction is unsigned and won't overflow, whereas addition is signed and overflow is possible.
According to Heinermann, whom I regard as the only expert on that matter here, said that actions (this includes additions and subtractions) are signed.
So I'd say conditions are unsigned, and subtraction and addition are signed. Subtractions won't overflow, but additions can.




Nov 18 2009, 8:27 pm rockz Post #28

ᴄʜᴇᴇsᴇ ɪᴛ!

I guess there's no difference between signed and unsigned when it won't overflow.

12 - -20 = 0 (overflow required for real answer)
-12 - -20 = 8 (no overflow needed)



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Nov 18 2009, 9:15 pm O)FaRTy1billion[MM] Post #29

👻 👾 👽 💪

When using subtract it is signed because it will not let the result be < 0. If the result is not < 0, it wont matter (and why would you ever need to subtract a negative?). Everything else is irrelevant or unsigned... Set To being signed or unsigned is a joke because there is no arithmetic involved, and Add doesn't matter because signed/unsigned are treated the same and there are no special cases (like Subtract having no results < 0). If the conditions read them as unsigned, then by all means just call them unsigned. ;o



TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB - topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig - topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Nov 18 2009, 9:31 pm Wormer Post #30



Nude, what do you exactly mean when you say subtraction and addition are signed?



Some.

Nov 18 2009, 9:32 pm scwizard Post #31



Quote from O)FaRTy1billion[MM]
When using subtract it is signed because it will not let the result be < 0. If the result is not < 0, it wont matter (and why would you ever need to subtract a negative?).
Nah. I did some more testing and subtraction works like this:
Code
unsigned int death_sub(unsigned int ls, unsigned int rs) {
    if(rs >= ls) return 0;
    else return ls - rs;
}

Unless you can think of some sort of C code with signed numbers that displays behavior equivalent to how death counts behave.

If the numbers were signed and it checked to see if the result was less than 0, it would behave differently. For instance 0xFFFFFFFD - 0x00000001 would = 0 (it equals 0xFFFFFFFE), and 0x00000001 - 0xFFFFFFFD would = 4 (it equals 0).



None.

Nov 18 2009, 11:14 pm rockz Post #32

ᴄʜᴇᴇsᴇ ɪᴛ!

Um, 0xFFFFFFFD - 0x00000001 = 0xFFFFFFFC aka -3 - 1 = -4
0x00000001 - 0xFFFFFFFD = 0x00000000 aka 1 - -3 = 0.

The result can be less than 0, but it won't go from 0x00000000 to 0xFFFFFFFF, which would mean an overflow occurred. If you consider subtraction as always unsigned, then it works out perfectly.

@ Wormer, nude is saying Heinermann says that subtraction is signed.



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Nov 19 2009, 8:15 am Wormer Post #33



Quote from Wormer
Nude, what do you exactly mean when you say subtraction and addition are signed?
Quote from rockz
@ Wormer, nude is saying Heinermann says that subtraction is signed.
Yes, I want to know how he understands it.



Some.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[10:09 pm]
Ultraviolet -- let's fucking go on a madmen rage bruh
[10:01 pm]
Vrael -- Alright fucks its time for cake and violence
[2024-5-07. : 7:47 pm]
Ultraviolet -- Yeah, I suppose there's something to that
[2024-5-06. : 5:02 am]
Oh_Man -- whereas just "press X to get 50 health back" is pretty mindless
[2024-5-06. : 5:02 am]
Oh_Man -- because it adds anotherr level of player decision-making where u dont wanna walk too far away from the medic or u lose healing value
[2024-5-06. : 5:01 am]
Oh_Man -- initially I thought it was weird why is he still using the basic pre-EUD medic healing system, but it's actually genius
[2024-5-06. : 3:04 am]
Ultraviolet -- Vrael
Vrael shouted: I almost had a heart attack just thinking about calculating all the offsets it would take to do that kind of stuff
With the modern EUD editors, I don't think they're calculating nearly as many offsets as you might imagine. Still some fancy ass work that I'm sure took a ton of effort
[2024-5-06. : 12:51 am]
Oh_Man -- definitely EUD
[2024-5-05. : 9:35 pm]
Vrael -- I almost had a heart attack just thinking about calculating all the offsets it would take to do that kind of stuff
[2024-5-05. : 9:35 pm]
Vrael -- that is insane
Please log in to shout.


Members Online: RIVE