WTF Bites
-
@anotherusername said in WTF Bites:
you have to choose whether
(a/b)*b + a%b = a
or0 <= a%b < b
You can actually reconcile those quite easily by simply defining integer division as
⌊a/b⌋
.And piss off even more people? Do you know how many programs depend on
(|a| < |b|) => (a/b = 0)
?
-
@ben_lubar said in WTF Bites:
@dreikin negative numbers and modulo never works well. No matter what semantics you invent, it's always going to be confusing in some cases - you have to choose whether
a/b + a%b = a
or0 <= a%b < b
.I choose the latter based on two principles:
- The only non-controversial definition of modulus has its domain being the unsigned integers, thus its range [0, n], and
- The idea of modulus being cyclical, therefore going in the negative direction should wrap around the other side.
So I maintain it should be
(-1) % 9 == 8)
, and anything else should be special exceptions or .The
%
operator in most languages is not modulo - it is remainder.REMAINDER(-1, 9)
is-1
.Yes, but the C# documentation calls it modulus:
x % y – modulus. If the operands are integers, this returns the remainder of dividing x by y. If q = x / y and r = x % y, then x = q * y + r.
-
-
@anotherusername then I'll tell you - as many as those who depend on path to program files being
C:\Program Files
.
-
@anotherusername then I'll tell you - as many as those who depend on path to program files being
C:\Program Files
.Which, of course, includes many Microsoft products, yeah?
-
@anotherusername then I'll tell you - as many as those who depend on path to program files being
C:\Program Files
.Why would any program depend on division as a shortcut for (much cheaper) cmp+jump?
-
@anotherusername said in WTF Bites:
you have to choose whether
(a/b)*b + a%b = a
or0 <= a%b < b
You can actually reconcile those quite easily by simply defining integer division as
⌊a/b⌋
.Then, to borrow the
-1%9
example,-1%9 = 8
, so0 <= -1%9 < 9
-1/9 = -1
, so(-1/9)*9 + -1%9 = -1
...come to think of it, that would also mean that
x/2
is mathematically equivalent tox>>1
(for negative numbers in addition to positive ones). So that's kinda nice.If you have integer division round toward 0, then
x>>1
won't work the same on negative numbers.
-
Status: WTF with my SSD though...
-
@ben_lubar said in WTF Bites:
@anotherusername then I'll tell you - as many as those who depend on path to program files being
C:\Program Files
.Why would any program depend on division as a shortcut for (much cheaper) cmp+jump?
Why would any program escape special characters with their MD5 hashes?
-
is the ?
-
@blakeyrat said in WTF Bites:
Except some laptops cool through the keyboard, and will overheat if they're running with the lid closed. (I'm not sure what percentage.)
Microsoft chose the safe default here. Bitch and moan all you like.That's the sort of thing that the BIOS/system drivers(/whatever they're called these days) should have information about.
"Should". Microsoft has decades of experience fixing problems caused by people not doing what they should do.
-
@blakeyrat said in WTF Bites:
Except some laptops cool through the keyboard, and will overheat if they're running with the lid closed. (I'm not sure what percentage.)
Microsoft chose the safe default here. Bitch and moan all you like.That's the sort of thing that the BIOS/system drivers(/whatever they're called these days) should have information about.
"Should". Microsoft has decades of experience fixing problems caused by people not doing what they should do.
And they seriously don't get enough credit for it. So much of the time that people complain about something being broken and stupid, it's a conscious design decision to work around (a) users being stupid or (b) software manufacturers being stupid.
-
@brisingraerowing said in WTF Bites:
is the ?
The transfer rate should be a flat line. Unless Windows is actually just filling a 200Mb buffer, emptying it, and refilling it, instead of, you know, a buffer...
-
@tsaukpaetra Why not just cut and paste it instead of copying and pasting it? Instant.
-
@pie_flavor said in WTF Bites:
@tsaukpaetra Why not just cut and paste it instead of copying and pasting it? Instant.
That wasn't me who initiated the copy. 7-Zip is pants-on-head idiotic how it handles drag-drop operations.
-
@tsaukpaetra Do you use TC4Shell?
-
-
@tsaukpaetra said in WTF Bites:
@pie_flavor said in WTF Bites:
@tsaukpaetra Why not just cut and paste it instead of copying and pasting it? Instant.
That wasn't me who initiated the copy. 7-Zip is pants-on-head idiotic how it handles drag-drop operations.
7-Zip has an "extract here" option on the right click menu.
-
@ben_lubar said in WTF Bites:
@tsaukpaetra said in WTF Bites:
@pie_flavor said in WTF Bites:
@tsaukpaetra Why not just cut and paste it instead of copying and pasting it? Instant.
That wasn't me who initiated the copy. 7-Zip is pants-on-head idiotic how it handles drag-drop operations.
7-Zip has an "extract here" option on the right click menu.
Which is totally fine.
Doesn't mean it can't support drag and drop properly.
That's like making a notepad app that deletes two characters when pressing backspace, but your response would be "Well it has a built-in on-screen keyboard right there!".
-
@tsaukpaetra said in WTF Bites:
@ben_lubar said in WTF Bites:
@tsaukpaetra said in WTF Bites:
@pie_flavor said in WTF Bites:
@tsaukpaetra Why not just cut and paste it instead of copying and pasting it? Instant.
That wasn't me who initiated the copy. 7-Zip is pants-on-head idiotic how it handles drag-drop operations.
7-Zip has an "extract here" option on the right click menu.
Which is totally fine.
Doesn't mean it can't support drag and drop properly.
That's like making a notepad app that deletes two characters when pressing backspace, but your response would be "Well it has a built-in on-screen keyboard right there!".
I'm pretty sure Windows doesn't give 7-Zip enough information for it to implement drag and drop in the way you want.
-
@ben_lubar Hence, TC4Shell. Handles archives right in the Windows Explorer window.
-
you have to choose whether
(a/b)*b + a%b = a
or0 <= a%b < b
.The first one is the fundamental definition of
%
; given a definition of/
, that tells you what%
actually returns. Everyone implements it.The complication is that you've got to define (for a positive divisor) whether you round down or round to zero; what should
(-1) / 9
produce, -1 or 0? I personally prefer the round down rule as that partitions the number line into equally-sized segments with/
saying which segment you're in and%
saying where you are in the segment. But that's not what you get with most hardware/
implementations.You also need to do the same with negative divisors. The inequality definition is completely wonky for that. ;)
-
@ben_lubar said in WTF Bites:
@tsaukpaetra said in WTF Bites:
@ben_lubar said in WTF Bites:
@tsaukpaetra said in WTF Bites:
@pie_flavor said in WTF Bites:
@tsaukpaetra Why not just cut and paste it instead of copying and pasting it? Instant.
That wasn't me who initiated the copy. 7-Zip is pants-on-head idiotic how it handles drag-drop operations.
7-Zip has an "extract here" option on the right click menu.
Which is totally fine.
Doesn't mean it can't support drag and drop properly.
That's like making a notepad app that deletes two characters when pressing backspace, but your response would be "Well it has a built-in on-screen keyboard right there!".
I'm pretty sure Windows doesn't give 7-Zip enough information for it to implement drag and drop in the way you want.
If it can get the source file, unpack it to tmp, and copy tmp to target directory, it can also unpack source file straight to target directory.
-
@blakeyrat said in WTF Bites:
Except some laptops cool through the keyboard, and will overheat if they're running with the lid closed. (I'm not sure what percentage.)
Microsoft chose the safe default here. Bitch and moan all you like.That's the sort of thing that the BIOS/system drivers(/whatever they're called these days) should have information about.
"Should". Microsoft has decades of experience fixing problems caused by people not doing what they should do.
And that's exactly why I said “should”. Systems where the hardware drivers get that right work well; where it is wrong, they have all sorts of niggling problems and people fall back on ridiculous working practices to try to avoid the weird crashes. This is something that Apple get right with their systems, but when Windows is graced with hardware that works correctly then it is also damn good (had a Dell laptop once where this was right; it ran XP extremely well even in the early releases).
-
Speaking of
%
and , I found this little gem in our code this week.num_bytes = (4 - (4 - address % 4) % 4) % 4
-
@ben_lubar said in WTF Bites:
@tsaukpaetra said in WTF Bites:
@ben_lubar said in WTF Bites:
@tsaukpaetra said in WTF Bites:
@pie_flavor said in WTF Bites:
@tsaukpaetra Why not just cut and paste it instead of copying and pasting it? Instant.
That wasn't me who initiated the copy. 7-Zip is pants-on-head idiotic how it handles drag-drop operations.
7-Zip has an "extract here" option on the right click menu.
Which is totally fine.
Doesn't mean it can't support drag and drop properly.
That's like making a notepad app that deletes two characters when pressing backspace, but your response would be "Well it has a built-in on-screen keyboard right there!".
I'm pretty sure Windows doesn't give 7-Zip enough information for it to implement drag and drop in the way you want.
If it can get the source file, unpack it to tmp, and copy tmp to target directory, it can also unpack source file straight to target directory.
I'm pretty sure it unpacks to tmp and then hands it over to Windows Explorer. I don't think it knows where the target directory is.
-
@ben_lubar said in WTF Bites:
@tsaukpaetra said in WTF Bites:
@ben_lubar said in WTF Bites:
@tsaukpaetra said in WTF Bites:
@pie_flavor said in WTF Bites:
@tsaukpaetra Why not just cut and paste it instead of copying and pasting it? Instant.
That wasn't me who initiated the copy. 7-Zip is pants-on-head idiotic how it handles drag-drop operations.
7-Zip has an "extract here" option on the right click menu.
Which is totally fine.
Doesn't mean it can't support drag and drop properly.
That's like making a notepad app that deletes two characters when pressing backspace, but your response would be "Well it has a built-in on-screen keyboard right there!".
I'm pretty sure Windows doesn't give 7-Zip enough information for it to implement drag and drop in the way you want.
Um, you got that backwards. It's 7-Zip that's supposed to give Windows (or, rather, Explorer) information it needs to drag and drop, not the other way around.
From observation, 7-Zip's order of operations is:
- 7-Zip: The equivalent of "There's something that can be dropped, I'll let you know what it is when the drop is done."
- Explorer: when said action is done, Explorer asks 7-Zip "Ok, I know where stuff should go, what was that stuff?"
- 7-Zip: "Oh? You want to have the files? One sec, I need to get that list for you"
- 7-Zip: Extracts files to %temp%\Numbers
- Explorer: "WTF are you doing? I'm waiting..." (freeze waiting on 7-Zip)
- 7-Zip: "Ok, I got the files, here you go!"
- Explorer: "Ah, finally! Alright, imma copy them now" (since it wasn't a Shift-Drag)
- 7-Zip: "Ok, I'll wait until you're done, I need to make sure the files are deleted once you're done with them."
- Explorer: Copies the files. Oh, it's the same drive? No matter, it's a copy after all, the user knows what they're doing after all...
- Explorer: "Ok, I'm done, thanks!"
- 7-Zip: "K thx bai!"
- 7-Zip: deletes files from the temp folder it made.
What should have happened:
- 7-Zip: "Hey, there's something that can be dropped. It's not immediately available, but here's a list of the things and how to ask me for them."
- Explorer: "Alright, I know where I want to stuff this data. I can haz nao?"
- 7-Zip: "Sure, lemme grab you a stream for each of those files you're requesting." Extracts files requested on demand.
- Explorer: "Alright, thanks!" Reads stream and writes to the destination seamlessly, since as part of the first step (IIRC) file size and other meta was provided.
- 7-Zip: "I closed the stream, you got all the file."
- Explorer: "K thx bai"
From some quick google searches, this isn't even all that hard to do...
-
@tsaukpaetra The should have happened bit is exactly what TC4Shell does.
Also, doesn't WinRAR do the exact same thing 7-Zip does in that case?
-
@tsaukpaetra said in WTF Bites:
Status: WTF with my SSD though...
SSDs aren't guaranteed to have consistent write performance like an HDD. After filling up the internal buffer they may, like in your case, start getting bursty. I mostly see it with old USB flash drives.
-
@tsaukpaetra said in WTF Bites:
@brisingraerowing said in WTF Bites:
is the ?
The transfer rate should be a flat line. Unless Windows is actually just filling a 200Mb buffer, emptying it, and refilling it, instead of, you know, a buffer...
...sort of. Like I said, it's probably the drive doing it, because the transfer speed exceeds its write speed.
-
This post is deleted!
-
@blakeyrat said in WTF Bites:
Except some laptops cool through the keyboard, and will overheat if they're running with the lid closed. (I'm not sure what percentage.)
Microsoft chose the safe default here. Bitch and moan all you like.
Can I bitch and moan about how operating systems have access to thermal sensors and should react on overheating regardless of lid status?
-
@blakeyrat said in WTF Bites:
Except some laptops cool through the keyboard, and will overheat if they're running with the lid closed. (I'm not sure what percentage.)
Microsoft chose the safe default here. Bitch and moan all you like.
Can I bitch and moan [snip of irrelevant details]
Yes.
-
https://i.imgur.com/39b0PHo.png
Excuse me?
The only thing I've installed since I last checked here was Homefront. Via STEAM, for chrissakes. A game from 20-fucking-11, not least one installed by Steam, should not be writing all of its installation files to the root of the drive that it's on, and then not deleting them afterwards.
-
Flash
I am hoping (though I should probably know better) that our internal training portal's going to migrate off it one of these years.
That said, I'm pretty sure they pushed me a flash update some time last month?
-
AdobeSomeone should make a FLA/SWF to WebAssembly compiler/transpiler, if there isn't one already.
-
Speaking of
%
and , I found this little gem in our code this week.num_bytes = (4 - (4 - address % 4) % 4) % 4
Is it possible for
address
to be negative?
-
@tsaukpaetra said in WTF Bites:
7-Zip is pants-on-head idiotic how it handles drag-drop operations.
Actually that's a limitation of Windows that the 7zip devs did their best to work around.
Why does drag-and-drop archive extraction from 7-Zip to Explorer use temp files?
7-Zip doesn't know folder path of drop target. Only Windows Explorer knows exact drop target. And Windows Explorer needs files (drag source) as decompressed files on disk. So 7-Zip extracts files from archive to temp folder and then 7-Zip notifies Windows Explorer about paths of these temp files. Then Windows Explorer copies these files to drop target folder.To avoid temp file usage, you can use Extract command of 7-Zip or drag-and-drop from 7-Zip to 7-Zip.
-
@anotherusername said in WTF Bites:
Is it possible for address to be negative?
No, it's a
uint32_t
(except this is actually Python, not that it matters) and the actual range of valid addresses at that particular point doesn't include any with the top bit set anyway. It's just an overcomplicated way to writeaddress % 4
.
-
@lb_ Toby Faire, Windows doesn't need real files on disk. 7zip could provide a wrapper that decompresses the files on demand while Windows reads from the file stream. Packed archives would be tricky, but should still be doable (it could even buffer the decompressed data to temp files if it needs to... as long as the wrapper grabbed the data from the right place when Windows was ready for it then it should work just fine).
-
@anotherusername said in WTF Bites:
Is it possible for address to be negative?
No, it's a
uint32_t
(except this is actually Python, not that it matters) and the actual range of valid addresses at that particular point doesn't include any with the top bit set anyway. It's just an overcomplicated way to writeaddress % 4
.If there value could be negative then it would effectively be
address % 4
where the modulo operator is defined to always return a value in the range0 <= x < 4
.If the address can't be negative, though, it's pointless, as you correctly said. Could be a programmer's habit to always "fix" it, though, because they want it to work that way instead. The fact that it couldn't ever be negative in that specific case may have been mainly just coincidental.
-
@pie_flavor It's using that C++ runtime whose redist installer had that bug, for like a week something like 7 years ago, and yet no developers fucking patched it and you still see those junk files written in your D drive even now in 2017.
-
Actually that's a limitation of Windows that the 7zip devs did their best to work around.
Not really; they could stream the decompressed file to Explorer in memory instead of using temp files.
The problem they've solving is valid, but their solution isn't the only one (or necessarily the best one.)
-
@anotherusername said in WTF Bites:
The fact that it couldn't ever be negative in that specific case may have been mainly just coincidental.
Given that the
address
variable in question definitely refers to a location in RAM of a 32-bit system with quite a lot less than 2GB of memory available, the possibility of negative values is in the “lol nope” range. And this code was definitely written more recently than the hardware was made, by several years. You can't sugar-coat this; this code is just unpleasant and silly.
-
@dkf I think you missed my point. The programmer might always write
(b - (b - a % b) % b) % b
, simply by habit, and might have not even stopped to consider whethera
could be negative in that specific case.
-
@anotherusername Really, no. I have the commit history of the code. I know the two programmers to blame. They are definitely too good at “just put this in in case it is sometime needed by someone” (it never is) but in this case, it evolved out of gradually inlining bits and never had any real care taken over it.
-
Given that the address variable in question definitely refers to a location in RAM of a 32-bit system with quite a lot less than 2GB of memory available, the possibility of negative values is in the “lol nope” range.
Until you upgrade hardware. Which will happen eventually.
-
Until you upgrade hardware. Which will happen eventually.
Actually, we're in the process of doing that. The new system will only have 2GB. (It's an embedded processor hooked up to some specialised stuff.) We really know to not worry about the limit.
And if we ever switch to a 64-bit CPU core, those
4
s will need to be changed too.
-
Given that the address variable in question definitely refers to a location in RAM of a 32-bit system with quite a lot less than 2GB of memory available, the possibility of negative values is in the “lol nope” range.
Until you upgrade hardware. Which will happen eventually.
It still wouldn't have negative addresses, though. And an unsigned integer type shouldn't have problems with values larger than
INT_MAX
... unless you're ...
-
@anotherusername so, is it uint32, or Python? Because Python doesn't have unsigned ints.