avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Sunday August 14, 2022, 5:33 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: What Every Computer Scientist Should Know About Units of Measurement  (Read 3137 times)


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 27
    • View Profile
    • Arca Eclipse (chatserver for ares)
    • Donate to Member
While developing some code at work i decided to write a class called Unit that would handle all translations between units of measurement. from seconds to minutes, meters to kilometers, bytes to bits, etc. a nobel task to ease the burdon of other developers in the team and to reduce errors in their code. so i started and made my class, and after finishing it i debugged it of course :)

now, end of story right ...    nope!!!

after writing a pricing engine for a new satallite system i found out it was impossible to use my class and get correct results! i kept debugging and debugging, and after having debugged the unit class several times i decided to take a real close look at it and super debug it once more.

so now we have the end of the story right?   ... nope...

yet again the super debugged unit class was giving trouble and it took me a whole night of stepping and debugging to realize something trivial. units word really odd! there are units that translate as follows:

1 minute = 60 seconds (this makes the factor 60 and we need to multiply to get from minutes to seconds)

then we also have:
60 calls per minute = 1 call per second (this makes again the factor 60, but instead of multiplying to get from minutes to seconds we need to divide this time!)

it turned out that all my troubles came from forgetting that unit per unit translates diffrent then a unit by itself!

the moral: you can make a reusable class for "Units of Measurement" and to translate them into eachother, but don't forget that there are 2 types of translations!


  • Charter Honorary Member
  • Joined in 2005
  • ***
  • default avatar
  • Posts: 1,321
    • View Profile
    • Donate to Member
My physics teacher tought me to do these types of translations seperately: First figure out the units, and totally disregard the numbers. Then "do the math" without any units.  :huh:

After you have the result, triple checked you used the correct units, and moreover the correct magnitudes of the units. It seems like more work, but I found it very easy. It's variation of the principle of KISS (keep it simple, stupid), conveniently also called KISS (keep it seperate, student).  :D :P