An integer overflow (or wraparound) occurs when a number larger than the max integer value or smaller than the min integer value is tried to be stored in the integer's memory. You could imagine a circular number line.
Ex: If you have an integer at the max positive value and add one, then the integer will wraparound and be set to the most negative value (if using a signed int. An unsigned int will wraparound to 0). And, vise-versa.
Today, I experienced a bug where I wanted to get a (signed) integer overflow, but unfortunately the int value was just going to zero instead of going to the negative numbers. Thankfully, I knew the memory/bit representation of int and was able to figure out what was going on.
Here is some simplified code, with only one small change:
// Test #1 - has wraparound
int wrap = 1;
for (int i = 0; i < 34; i++) {
print(i + ": wrap: " + wrap);
wrap = wrap * 3;
}
// Test #2 - no wraparound
int wrap = 1;
for (int i = 0; i < 34; i++) {
print(i + ": wrap: " + wrap);
wrap = wrap * 2;
}
Here is the relevant output from running the code above:
// Test #1 - has wraparound
...
13: wrap: 1594323
14: wrap: 4782969
15: wrap: 14348907
16: wrap: 43046721
17: wrap: 129140163
18: wrap: 387420489
19: wrap: 1162261467
20: wrap: -808182895
21: wrap: 1870418611
22: wrap: 1316288537
23: wrap: -346101685
24: wrap: -1038305055
25: wrap: 1180052131
26: wrap: -754810903
27: wrap: 2030534587
28: wrap: 1796636465
29: wrap: 1094942099
30: wrap: -1010140999
31: wrap: 1264544299
32: wrap: -501334399
33: wrap: -1504003197
// Test #2 - no wraparound
...
20: wrap: 1048576
21: wrap: 2097152
22: wrap: 4194304
23: wrap: 8388608
24: wrap: 16777216
25: wrap: 33554432
26: wrap: 67108864
27: wrap: 134217728
28: wrap: 268435456
29: wrap: 536870912
30: wrap: 1073741824
31: wrap: -2147483648
32: wrap: 0
33: wrap: 0
If test #1 were to continue, then the values would keep wrapping. If test #2 were to continue, then the values would stay the same at 0.
The easiest way for me to make sense of this experiment was to know that multiplying by a power of 2 (2, 4, 8, 16, 32..) is the exact same as a bit shift in the binary computer. And, the bits that made up the int were all just getting pushed out of memory in test #2 until there were no more set bits to manipulate. In test #1, more int memory bits are being flipped in order to continue the wraparound.
I would explain this at a lower level, but there are already many great resources for "bit representation of integer".
~ Danial Goodwin ~
ps - This post was mainly for myself and written quickly. If there are any questions about this, then I'd be happy to elaborate.
Showing posts with label wrap. Show all posts
Showing posts with label wrap. Show all posts
2014-06-18
2014-03-22
Level Up!: Do Users Need To Click "I Agree" to TOS Button To Give Consent?
(TLDR: No. Courts decide these cases simply by whether the person had reasonable notice of the Terms & Conditions. If you have a website/app and plan on collecting personal info or just have customers in general, the I highly suggest you read more about this topic. Disclaimer: IANYL.)
As a UX designer, I try to make things that are as simple and painless as possible for users to use. One pain (and protection) that almost every product/app needs is a Terms of Service (TOS) agreement, aka Terms of Use (TOU), aka Terms And Conditions (T&C), aka End User License Agreement (EULA).
The current "best practice" for showing TOS to users is by providing a clear link near the "continue to use app" button (which could be a register or purchase button). This is so that most users don't have to go through the extra step of clicking "I Agree" to something that they likely didn't read. Also, having the TOS pop-up interrupts users' flow (and can sometimes be quite scary-looking).
But, unfortunately, before today, I never really thought about the legal consequences of the different methods to show users the terms and conditions. I just used methods that I noticed many other great UX designers and companies using. So, I wasn't able to explain the legal-ness (to my satisfaction) to concerned client.
I took it upon myself to take the time to do some research around this area and organize it into this post, with sources and references cited.
In my research, I have found that the courts also know that most users don't read the TOS, and clicking "I agree" doesn't mean that the user has read it. What the courts look for is mainly that the user has had the easy opportunity to find and read the TOS, if they wanted to.
There are two main ways that users "agree" to TOS:
My Summary (Just from my research (links below), though more can always be done.)
A few sources I read, in order of my recommended readings (Yes, there is a "Good" before "Great", just because of what this post was supposed to be about):
- Great: How Zappos' User Agreement Failed In Court and Left Zappos Legally Naked (Forbes)
- Great: The Clicks That Bind: Ways Users "Agree" to Online Terms of Service (EFF)
- Good: Terms Of Use And Privacy Policy Best Practices (UpCounsel)
- Great: Website Terms and Conditions: Some Best Practices (JDSupra)
- Miscellaneous, but good: Terms of Service; Didn't Read (TOSDR)
- Good: Browse wrap (Wikipedia)
- Okay: Clickwrap / Browsewrap Agreements: It’s the Notice, Stupid!
Further Reading:
- Terms of Use and the Digital Millennium Copyright Act (DCMA)
- Search "Clickwrap vs browsewrap"
Disclaimer: I am not your lawyer (IANYL). This post's only intention is to help point readers in the right direction to learn more about this topic.
~ Danial Goodwin ~
ps - Bonus info! The terms "click-wrap" and "browse-wrap" come from physical goods/software that was "shrink-wrapped". Manufacturers had license agreements that basically said users agree to TOS by removing the shrink-wrap. (Source: Wikipedia)
As a UX designer, I try to make things that are as simple and painless as possible for users to use. One pain (and protection) that almost every product/app needs is a Terms of Service (TOS) agreement, aka Terms of Use (TOU), aka Terms And Conditions (T&C), aka End User License Agreement (EULA).
The current "best practice" for showing TOS to users is by providing a clear link near the "continue to use app" button (which could be a register or purchase button). This is so that most users don't have to go through the extra step of clicking "I Agree" to something that they likely didn't read. Also, having the TOS pop-up interrupts users' flow (and can sometimes be quite scary-looking).
But, unfortunately, before today, I never really thought about the legal consequences of the different methods to show users the terms and conditions. I just used methods that I noticed many other great UX designers and companies using. So, I wasn't able to explain the legal-ness (to my satisfaction) to concerned client.
I took it upon myself to take the time to do some research around this area and organize it into this post, with sources and references cited.
In my research, I have found that the courts also know that most users don't read the TOS, and clicking "I agree" doesn't mean that the user has read it. What the courts look for is mainly that the user has had the easy opportunity to find and read the TOS, if they wanted to.
There are two main ways that users "agree" to TOS:
- Click-wrap Agreement, aka "click-through agreement": This means that users must take some sort of action that signifies their consent to the TOS. This action could be a button that says "I Agree". Also, near the call to action, it is sufficient to say "By [continuing], you agree to our Terms of Service", with the TOS having a direct link.
- Browse-wrap Agreement, aka "not a contract": Basically, saying users agree to TOS by browsing website/app, and the link to TOS is not extremely easy to find in regular use. A link at the bottom of the website could be considered hard to find, especially when there are many other links down there too.
My Summary (Just from my research (links below), though more can always be done.)
- If your app collects or uses personal information, then use the click-through (clickwrap) agreement.
- Remove any clauses about unilaterally editing contract at any time.
- Add ability for company to modify terms, with prior notice. [More research needed for exact words to use]
- Add ability for users to reject TOS, e.g. by terminating account.
A few sources I read, in order of my recommended readings (Yes, there is a "Good" before "Great", just because of what this post was supposed to be about):
- Great: How Zappos' User Agreement Failed In Court and Left Zappos Legally Naked (Forbes)
- Great: The Clicks That Bind: Ways Users "Agree" to Online Terms of Service (EFF)
- Good: Terms Of Use And Privacy Policy Best Practices (UpCounsel)
- Great: Website Terms and Conditions: Some Best Practices (JDSupra)
- Miscellaneous, but good: Terms of Service; Didn't Read (TOSDR)
- Good: Browse wrap (Wikipedia)
- Okay: Clickwrap / Browsewrap Agreements: It’s the Notice, Stupid!
Further Reading:
- Terms of Use and the Digital Millennium Copyright Act (DCMA)
- Search "Clickwrap vs browsewrap"
Disclaimer: I am not your lawyer (IANYL). This post's only intention is to help point readers in the right direction to learn more about this topic.
~ Danial Goodwin ~
ps - Bonus info! The terms "click-wrap" and "browse-wrap" come from physical goods/software that was "shrink-wrapped". Manufacturers had license agreements that basically said users agree to TOS by removing the shrink-wrap. (Source: Wikipedia)
Subscribe to:
Posts (Atom)