• Anonymous') OR 1=1; DROP TABLE wtf; -- (unregistered)

    The New Zero is a really catchy song, that was my frist time hearing it. Thanks for sharing!

  • trainbrain27 (unregistered)

    Was that better than a formula? Throw an exception or 0 for 0 weight then go from 17x+5 to 20x+5.

    I wasn't programming back then, so I don't know if looking up an array was significantly faster than basic math.

  • The Beast in Black (unregistered) in reply to trainbrain27

    I doubt that the real prices were amenable to a formula; Remy did say that the numbers in the post were only illustrative.

    Kudos to you for deriving that, though!

    If you look at real USPS prices today, you'll find all sorts of complications due to non-integer prices, different categories of stuff, stuff with slab rates, and so on.

    Even back in 1988, I'm guessing that - in the absence of some DB-adjacent solution - a lookup table was probably the most workable solution.

  • Argle (unregistered) in reply to trainbrain27

    In answer to your question, it's indeed possible to have a table be more useful. Back in the day, I owned an Amiga. The 68000 CPU was a nice machine, but I had a long loop that needed squares of 0 through 255. I did some tests and indeed found that it was faster to have a table of all those squares rather than doing the multiply in the loop. "Ah, but what about negatives?" Well, C being what C is and not having bounds checking, I wrote something like:

    static int negatives[] = { /* values left out*/, 25, 16, 9, 4, 1 }; static int squares[] = { 0, 1, 4, 9, 16, 25, 36, /* etc */ };

    If you index 'squares' by a negative value, it just pulled from the array in memory before it. This is horrible practice and I'd never do it today, but it worked a treat for performance on that old machine.

  • DigitalBits (unregistered)

    Octal is such a terrible idea. The fact that some languages treat 13 and 013 as different is unintuitive and causes weird bugs.

    Prefixes (or suffixes) are much better. 0b, 0o, 0x. No confusion then.

  • Balor64 (unregistered) in reply to Argle

    I'm pretty sure you can do that without the undefined behavior, though I doubt it'd be worth doing on a modern machine anyway.

    static int squaresArray[] = { /* values left out*/, 25, 16, 9, 4, 1, 0, 1, 4, 9, 16, 25, 36, /* etc */ }, *squares = squaresArray + 255;

    return squares[index];

  • (nodebb)

    One of my own nasty 'C' bugs in the 80's was looking for a space character like this:

    if ( c == ' ' )

    Unfortunately, what I thought was a space was actually a tab character in column 16. I only found the problem by compiling to assembler and reading the assembler. Java and many languages have the same problem today. Even Python, which depends on indentation for flow control, doesn't complain about this issue.

  • Gnasher729 (unregistered)
    Comment held for moderation.
  • jaswanth (unregistered)
    Comment held for moderation.
  • pacheron (unregistered) in reply to Balor64
    Comment held for moderation.

Leave a comment on “Best of 2022: Padded Mailers”

Log In or post as a guest

Replying to comment #590770:

« Return to Article