Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "underflow"
-
Fun fact:
In the game Civilization, Gandhi had a aggression rating of 1 which means he didn't declare war on anyone. Now whenever someone Researched Democracy their aggression rating dropped by 2. Now instead of it dropping to - 1, it caused an integer underflow and the aggression rating became the highest possible value, making Gandhi into a nuclear warlord. He nuked everyone!20 -
Just noticed that it's possible to get a negative vote count on a devRant profile. So I'm wondering if it's possible to underflow the vote count? @dfox3
-
I just saw some loan/bank ad that read something around the line "when the budget goes negative, the minus becomes plus" ("Când bugetul dă cu minus, minusul se face plus")
NO, this isn't a feature, it's a bug and it's called "underflow"4 -
So I get three wishes, right? Great! I wish I lose 3 wishes.
By that logic I start at three, minus one for the wish, and then proceed to lose another three leaving me at -1. So by our logic, we’d be back at 3 due to underflow.
To exploit this, make one genuine wish and then ask to lose two wishes, underflowing again.
It’s all in how you play the game.8 -
I really love Django, but I feel like Python is not object oriented enough. I'm thinking about Play (the Java web framework). Any other suggestions?10
-
A bit longer rant, somehow triggered by the end of this rant:
https://devrant.com/rants/7145365/...
The discussion revolved around strpos returning false or a positive integer.
Instead of an Option or a Exception.
I said I'm a sucker for exception, but I'm also a sucker for typing.
Which is something most languages lack - except the lower level ones like C / C++.
I always loved languages which have unsigned and signed types.
There, I said it... :) I know that signed / unsigned is controversial, Google immediately leads to blog entries screaming bloody murder because unsigned can overflow – or underflow, if someone tries to use a -1on an unsigned integer.
Note that my love is only meant for numeric types, unsigned / signed char is ... a whole can of insanity on its own.
https://phoronix.com/news/...
If you wanna know more.
Back to the strpos problem, now with my secret love exposed:
strpos works on a single string, where a string is a sequence of chars starting with 0.
0 is a positive integer.
In case the needle (char that should be looked up in the string) cannot be found in the haystack (the string), PHP returns "false".
This leads to the necessity of explicitly checking the type as "0" (beginning of string, a string position)... So strpos !== false.
PHP interprets 0 as false, any other integer value is true.
In the discussion, the suggestion came up to return -1 if a value could not be found – which some languages do, for example Scala.
Now I said I have a love for unsigned & signed integers vs. just signed integers...
Can you guess why the -1 bothers me very much?
Because it's a value that's illogical.
A search in a sequence that is indexed by 0 can only have 0 or more elements, not less than zero elements.
-1 refers to a position in the sequence that *cannot* exist.
Which is - of course - the reason -1 was chosen as a return value for false, but it still annoys me.
An unsigned integer with an exception would be my love as a return value, mostly because an unsigned integer represents the return value *best*. After all, the sequence can only return a value of 0 ... X.
*sigh*
Yes, I know I'm weird.
I'm also missing unsigned in Postgres, which was more or less not implemented because it's not in the SQL standard...
*sob*30