u/RefrigeratorNorth331

Help me figure out a weird integer storage thing?

The full story is pretty long, so here’s the tl;dr: why would something that is seemingly storing integers start storing only even numbers—rounding odd numbers to the closest even above them—once a particular threshold is exceeded?

The story: I work at a cafeteria, and sometimes I get assigned to cover breaks for the cashiers. I work the night shift so it can get quite slow, no customers for several minutes at a time. During one of these lulls, with nothing better to do, I start messing around with the buttons on the cash register, and I notice that there’s a “misc” option, that lets you add a charge for a custom amount. For the heck of it, I decide to test the limits of the software the cash register runs on, I spam the number nine in the input box (already way more than you could spend at the cafeteria, probably more than there is currency in circulation), I hit enter and the register handles it without a problem, displaying a charge for the full amount as I typed it in. Over a few minutes, I hone in on the max value the register will accept (it just throws an error when the number is exceeded), at first counting out nines to get the approximate length, then fiddling with the leading digits for precision. At some point while doing this, I realized I had enough digits to match the number to a power of two, since that would be a likely upper bound. I pull up a calculator on my phone and sure enough, after a few attempts to get into the right range, I find a match: 2^96. This is the first thing that strikes me as odd, I was expecting the number of bits to be a power of two, I know it doesn’t Need to be that way, just a common convention. Going back to the register, I try my luck with 2^96-1, but to my surprise, it gives me the out of bounds error, not really thinking about why this would work, I try 2^96-2, and for some reason it Does work. This was such a counterintuitive result at first that I concluded that I must have typed something in wrong the first time around and tried 2^96-1 again, still nothing. Next step was to double check 2^96-2, maybe I had missed a number, or accidentally substituted a smaller digit at some point? Nope. Curious, I try 2^95-1, and that’s when I realize that the register is rounding up to the next even number, displaying “…5168” instead of “…5167.” I decide that my next task is obvious: find where it transitions from including every positive integer, evens and odds, to only showing evens. 2^94-1? Rounds to an even. 2^93-1? Rounds to an even. But not 2^92-1, now we’re getting somewhere. I spend a few minutes doing a manual binary search and notice something interesting about the four largest terms: 2^92+2^91+2^88+2^87-1 did not round, but 2^92+2^91+2^88+2^87+2^86-1 did. Going out on a limb, I add up the powers of two congruent to zero or three modulo four up to 2^92 (from now on I’m calling this number n). n-1 doesn’t round, good start, and n+1… also doesn’t round. Rats. But then, paydirt: n+3 rounds up from 7922816251426433759354395035 to 7922816251426433759354395036. But now we come back to the question: why? My first thought was that maybe it was a way to squeeze a little extra range out of a fixed number of bits, but that doesn’t quite make sense, you would need to skip every other number starting at zero to get up to the power of two higher than the number of bits you have. Starting at 7.9 octillion in particular would, in getting to 2^96-2, overshoot the number of numbers you can represent with 95 bits by roughly 4 octillion (yeah, i know it’s just half of the value i gave for n, big numbers are just fun to say sometimes). Honestly, I’m at a loss here, I even considered maybe I was wrong about the value being stored as an integer, but if it is a float of some sort, I can’t figure out what the encoding would look like. I hope this was at least a little fun to read, it was an entertaining little project (even outside the context of being bored at work), but now I’m at a point where I don’t know how I would proceed on my own.

P.S. I did kinda stretch the truth in the story, that didn’t all happen in one sitting while I was covering a coworker’s shift, it was stretched out over several days, a few minutes at a time, I just didn’t feel like breaking up the narrative with “and then their break was over so I had to leave”

reddit.com
u/RefrigeratorNorth331 — 4 days ago

Sublease 2bed/1bath Iowa City

My roommate and I want to move out of our apartment before our lease ends on July 16th, it should be available for moving in late July/early August. Our unit is pretty close to downtown, about a 15minute walk away from University of Iowa campus, and there are bus stops to and from campus one block away. Please let me know ASAP if you’re interested. Rent is $1109/month

reddit.com
u/RefrigeratorNorth331 — 8 days ago

Are there any manufacturers that let you listen to the button-press sounds before buying a pair?

Is there a reviewer who has compiled the sounds for several different pairs of headphones?

No one seems to care about this but the audio interface is a big priority for me accessibility-wise. My number one priority is avoiding headphones that use a voice for one of the functions (e.g. “power on,” or “bluetooth connected,” or “noise-canceling on,” stuff like that). My second priority is minimizing loud/obtrusive noises, a particularly egregious example of this is the low battery warning on the TOZO HT2 headphones, it’s loud, grating, interrupts audio without pausing it so you have to go back a few seconds to hear what you missed, and it plays once every few minutes for ages (so it wasn’t really that low on battery when it started playing the warning), I want a low battery warning that is quiet and plays only once, a half hour or so before they automatically shut off.

Per my first priority item, if nothing else, I would like to have a list of headphones that don’t use voice clips in their audio interface, so if you have a pair that meets that requirement, feel free to comment the brand and model, I would super appreciate it.

reddit.com
u/RefrigeratorNorth331 — 25 days ago

I just learned about this from someone on a separate post, and I don’t even really know what it is or is supposed to do. My end goal is to rewrite the firmware on a pair of bluetooth headphones in order to customize the button-press sounds it plays. Is it even possible to do something like that by reprogramming the BIOS chip? How would I go about

  1. downloading the file (is it even a file? I’m going to keep referring to it that way because I don’t know what else to call it) I would need to edit from my headphones.

  2. reading the file so I know what I’m looking at.

  3. customizing it without making the headphones unusable (I have a physically broken pair that I can tinker with, and I figure if I brick those, I’ll just call it quits and not risk destroying a perfectly good pair of headphones)

  4. putting my version of the file onto my headphones

Sorry for the high likelihood that this is all complete nonsense because I have no idea what I’m talking about. I’m somewhat hoping someone will tell me: “You have no idea what you’re talking about, This is what you need to be looking into instead. (and/or) This is the subreddit you need to ask.”

reddit.com
u/RefrigeratorNorth331 — 25 days ago