• Buddahriffic@lemmy.world
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    28 days ago

    Variables can be in arbitrary units. If you put the units through the same steps as the values, you’ll end up with the right unit, plus you need the values to be in compatible units for the operations to even make sense. At least as long as any constants are also given the correct units. This can also help discover cases where you accidentally mix similar but different units (like litres and gallons).

    I also find it very satisfying to do those equations on the units, adding ones that get multiplied in and cancelling ones that get divided out, and then ending up with a unit that makes sense, given what the equation was supposed to express.

    Though we might be saying the same thing, because while I don’t think variables need units, expanding that variable with a value absolutely should involve a unit, as should any examples of that equation’s use.

    Edit: an example to show what I mean:

    If you have a table that is 1.5m long and know that you want at least 2 feet between the wall and the table on each side so that people can get in and out if chairs comfortably, you’d have 1.5m + 2*2ft as the equation, but you can’t add an m to a ', so you need to multiply one of them by a conversion factor:

    1.5m + 2 * 0.3048m/ft * 2ft

    The ft terms cancel out and you’re left with

    1.5m + 2 * 0.3048m * 2

    = 1.5m + 1.2192m

    ~= 2.72m

    So your space must be at least 2.72m to fit that table and chairs comfortably (by the above definition of comfort, at least).

    Funny enough, this use of units helped me avoid a mistake in this example because I had the ft/m conversion initially but saw that would result in trying to add m to ft² so it was obvious that I had made a mistake. Otherwise I might have looked like an idiot trying to say that a 1.5m table with 4 feet of buffer space requires a room over 12m long.

    • Someonelol@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      4
      ·
      28 days ago

      Yeah it’s stuff like this that can make a huge problem like with the Mars Climate Orbiter crashing because its programmers were mixing and matching SI and Imperial units. Adding a few minutes to a document can save hours of looking stuff up for the reader later.

    • exasperation@lemm.ee
      link
      fedilink
      English
      arrow-up
      3
      ·
      28 days ago

      But imagine describing an area in meter•feet instead of square feet or square meters. That could really piss everyone off.