Blog Post

Converting Inches to Centimeters - Long Hand

,

Today I had to write a little function that takes the long had version of a fraction, say 8 3/4 and convert it a proper number (float) and then convert that number from inches to centimeters. While that is handy, I thought it would be best to include a few more variations on that theme.  It handles the following input scenarios:

  • Whole numbers -- '8'
  • Fractions alone -- '1/4'
  • Mixed Numbers -- '8 1/4','8-1/4','8.25','0.75','.75'
  • An invalid fraction -- 'Special',' eight and 1/4'

I'd list the code, but I haven't found a good way to embed formatted code into this website so instead I am linking the source code.

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating