Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
klafbang
Nov 18, 2009
Clapping Larry

Carbon dioxide posted:

There are no decimals. The chip supports all integer values between -999 and +999 inclusive (but the in/output on the analog p0 and p1 pins is always mapped to a number between 0 and 100).

You don’t need decimals to be able to turn division into multiplication. If we look at algebra, what computers do is basically computations in the ring Z/nZ where n is the number of different numbers (so 1999 in the example, often 232 or 264 in real computers).

That means computation is not our regular operations, but rater the operations “modulo n,” which is good enough in most cases. modulo just means “the remainder after division by n,” so for example 4 + 7 modulo 10 is 11 modulo 10 = 1 and 3 * 5 modulo 10 = 15 modulo 10 = 5.

The reason this is useful for division is because it is possible for two integers to be multiplied and get 1. For example, 3 * 7 modulo 10 = 21 modulo 10 = 1. In a sense, 7 = 1/3 modulo 10.

Consider 9 / 3 = 3. Also, 9 * 7 modulo 10 = 63 modulo 10 = 3. Hey, that works! Similarly, 6 * 7 modulo 10 = 42 modulo 10 = 2.

The condition for a number to have an inverse is that it has to be coprime with n. That means the largest common factor between the number and n has to be one. For example, 2 does not have an inverse modulo 10; we cannot find a number that multiplied with 2 yields a number with remainder 1 when divided by 10 (such a number would be odd, and 2 multiplied by any integer is even) because 2 and 10 have a common factor of 2. 4, 5, 6, and 8 also don’t work, but the inverse of 9 is 9 (9 * 9 modulo 10 = 81 modulo 10 = 1, so division and multiplication by 9 is the same modulo 10).

For this machine, though, n = 1999, which is a prime. That means that *every* number has an inverse, and we can divide by any number using multiplication! (Assuming that the machine behaves “sensibly” for a certain value of sensibly during overruns.). Try dividing by 42 by multiplying by 238 (after adding 999 to move the value to the interval 0-1998).

We have to be careful with fractions; for example, what is 8 / 3? Well, 8 * 7 modulo 10 = 56 modulo 10 = 6, which seems a bit weird; we would expect either 2 or 3. 6 is the correct answer, though, because 6 * 3 modulo 10 = 18 modulo 10 = 8.

This corresponds to how we can compute a - b by finding the inverse of b (often called -b) and using addition as a - b = a + (-b).

This actually has uses in cryptography.

klafbang fucked around with this message at 22:07 on Aug 16, 2018

Adbot
ADBOT LOVES YOU

klafbang
Nov 18, 2009
Clapping Larry

Sydin posted:

Yeah I've liked the LP direction so far of "show off a rudimentary design that fulfills the specs but nothing more, then a second round of refining the solution and explaining it. It's pretty much how I approached the game back when I was obsessed with it: first you solve the problem, then you solve it elegantly.

I agree with this, and add that I also like that the “best” solution isn’t shown but left as an exercise to the thread.

klafbang
Nov 18, 2009
Clapping Larry

AceOfFlames posted:

I think there's a sci-fi story about something like this, though I don't remember what it was called.

Maybe you're thinking of reality

klafbang
Nov 18, 2009
Clapping Larry

Quackles posted:

This strikes me as something that could work, though I have to wonder - who would want that many sandwiches made in an automated manner (as opposed to making them themselves)? What if you fill the mustard compartment with mayo? The keypad still says 'mustard'. What about if you want extra cheese and no mustard?
Heck, what if you're Canadian?

TLDR: This doesn't look that customizable in the grand scheme of things, and I'm having a hard time thinking of applications. This doesn't mean that 'personal sandwich maker' is a bad idea. You could probably make a more programmable and versatile design and sell lots of units. Just... as it is now, this feels like junk.

But hey. Maybe Joe's on to something, and we can get rich selling junk.

Kickstarter it, but add DRM bread and an iPhone app.

klafbang
Nov 18, 2009
Clapping Larry
If somebody likes X86 assembler, I can recommend these videos.

The first one explains in simple terms (relatively) how the Meltdown vulnerability is exploited.

https://www.youtube.com/watch?v=I5mRwzVvFGE

These videos are much more involved; the first explains how this guy built a tool to find undocumented operations in CPUs:

https://www.youtube.com/watch?v=KrksBdWcZgQ

The second one explains how the same guy used that tool (from last year) to find an exploit in an obscure X86 clone that is millions of times worse than Meltdown:

https://www.youtube.com/watch?v=_eSAF_qT_FY

klafbang
Nov 18, 2009
Clapping Larry

Foxfire_ posted:

Conversely, there's a bunch of important optimizations for fancy chips that compilers are much better at doing than people.

Stuff like exactly how many times to unroll a loop before the code doesn't fit in an instruction cache anymore or making good guesses about what pieces of hardware inside a superscaler CPU are in use and reorganizing instruction so the hardware can overlap them.

Humans can do all those things too, but the benefit/time tradeoff is heavily weighted towards letting a machine do it.

The big reason for doing hand optimization is to make sure the branch prediction makes the right guesses (or doesn't have to make a guess by transforming conditional to algebraic computations or loop-ups).

Secondary, once you've spent a week or two hand-optimizing a tight loop, you get ideas for adjustments to the algorithm. I once worked on invisible watermarking of live video, and after standard vectorization and linearization, we made an adjustment to a precomputed grayscale gradient from 64 to 16 or 32 levels, allowing us to use in-CPU look-up-tables.

klafbang
Nov 18, 2009
Clapping Larry
Hotel security is typically super lax. I once stayed at one where the key system was broken, so after supplying me with 2-3 reprogrammed keycards, they just gave up and gave me a master key that could open every door at the hotel. When that is the attitude of the staff, there’s little reason in trying to make the technology any kind of tamper proof.

Adbot
ADBOT LOVES YOU

klafbang
Nov 18, 2009
Clapping Larry
Want the cool verdion

https://m.youtube.com/watch?v=1CqS3pRUbBI

Or the practical version?

https://www.hackster.io/sidlauskas/barbot-cocktail-mixing-robot-0318aa

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply