dennis-fedco Posted July 3, 2014 Share Posted July 3, 2014 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? Quote Link to comment https://forums.phpfreaks.com/topic/289423-how-to-handle-units-conversion/ Share on other sites More sharing options...
Jacques1 Posted July 3, 2014 Share Posted July 3, 2014 And why not store the input exactly as is together with the original system? If you convert everything into one base system, you have to be very careful not to accidentally change the input due to rounding errors. Quote Link to comment https://forums.phpfreaks.com/topic/289423-how-to-handle-units-conversion/#findComment-1483723 Share on other sites More sharing options...
dennis-fedco Posted July 3, 2014 Author Share Posted July 3, 2014 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. Quote Link to comment https://forums.phpfreaks.com/topic/289423-how-to-handle-units-conversion/#findComment-1483726 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.