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
https://forums.phpfreaks.com/topic/289423-how-to-handle-units-conversion/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.