• 3 Posts
  • 65 Comments
Joined 1 year ago
cake
Cake day: June 10th, 2023

help-circle


  • Only picked it up a few days ago.

    I went the dumb phone route in March of 2023 because I was constantly scrolling or getting distracted while I was out with my wife. (Still use my iPhone on WiFi at home). Found that it worked well for me, but there would be the occasional question I’d have and have no way to look it up besides asking to borrow my wife’s phone.

    She got annoyed, so I got the Rabbit used on eBay for $130. Got a $5/mo sim for it. I think it’s made a lot of improvement since initial launch comparing my experience to reviews. Battery life is well over a day for me, and I haven’t had it glitch out too terribly. Even the scroll wheel isn’t as bad as they say.

    You just have to assume that 20% of the time, it’s entirely wrong. Like Diane Keaton wasn’t in 1989’s Parenthood, it was Diane Wiess.

    I bought it under the assumption that the company would fold in a year or so, but there’s already a community rooting them and installing base Android. For $130, it’s worth whatever I can get out of it.

    Edit: also aware of the glaring security hole, so no personal questions to the R1











  • I believe the optimization came because the denominator was a power of two. In my memory, the function counted up all of the bytes being sent and checked to see that the sum was a power of 16 (I think 16 bytes made a single USB endpoint or something; I still don’t fully understand USB).

    For starters, you can split up a larger modulo into smaller ones:

    X = (A + B); X % n = (A % n + B % n) % n

    So our 16 bit number X can be split into an upper and lower byte:

    X = (X & 0xFF) + (X >> 8)

    so

    X % 16 = ((X & 0xFF) % 16 + (X >>8) % 16) % 16

    This is probably what the compiler was doing in the background anyway, but the real magic came from this neat trick:

    x % 2^n = x & (2^n - 1).

    so

    x % 16 = x & 15

    So a 16 bit modulo just became three bitwise ANDs.

    Edit: and before anybody thinks I’m good a math, I’m pretty sure I found a forum post where someone was solving exactly my problem, and I just copy/pasted it in.

    Edit2: I’m pretty sure I left it here, but I think you can further optimize by just ignoring the upper byte entirely. Again, only because 16 is a power of 2 and works nicely with bitwise arithmatic.