Jump to content

How to handle Units conversion?


dennis-fedco

Recommended Posts

I have an application where things are requested/computed/shown using either Metric or English systems. 

 

I am thinking that the best way to handle this is to store units in one system, i.e English (as I am in United States), and to only convert them to Metric for the View, when it is being requested.

And if Metric parameters are being inputted through a form, then convert them to English on input. 

 

So in a word

 

 *  store, compute, anything back-end, do it in English system.

When anything Metric shows up, then

 *  convert-on-output to Metric

 *  convert-on-input from Metric

 

Does that sound like a good plan?

Are there any other equally or better-than plans to deal with systems?

Link to comment
Share on other sites

I suppose I could do that.

 

That will mean though I need to deal with (and be aware of) different systems when doing computations.

And storing original system in the database along with system identifier as well.  Kind of seemed a bit murky to me

 

If I can come up with a simple rule-based schematic it will be okay

 

so let's see:

  * as-is on input

  * as-is on output

  * possibly having separate computation routines for each system, or at the least, keep track of which system it is during computations, in order to maintain proper units.

 

It just looked a bit more hairy to me.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.