|Determining the inverse function operation from a function definition email@example.com (Ron Foster) (2005-04-26)|
|Re: Determining the inverse function operation from a function definit firstname.lastname@example.org (2005-04-28)|
|Re: Determining the inverse function operation from a function definit email@example.com (Dmitry A. Kazakov) (2005-04-28)|
|Re: Determining the inverse function operation from a function definit firstname.lastname@example.org (Laurence Finston) (2005-04-28)|
|Re: Determining the inverse function operation from a function definit email@example.com (SM Ryan) (2005-04-28)|
|Re: Determining the inverse function operation from a function definit firstname.lastname@example.org (Dr. Diettrich) (2005-04-28)|
|Re: Determining the inverse function operation from a function definit email@example.com (2005-04-30)|
|Re: Determining the inverse function operation from a function definit firstname.lastname@example.org (glen herrmannsfeldt) (2005-04-30)|
|Re: Determining the inverse function operation from a function definit email@example.com (Dr. Diettrich) (2005-05-13)|
|From:||"Dmitry A. Kazakov" <firstname.lastname@example.org>|
|Date:||28 Apr 2005 14:32:01 -0400|
|Organization:||cbb software GmbH|
|Posted-Date:||28 Apr 2005 14:32:01 EDT|
On 26 Apr 2005 20:43:21 -0400, Ron Foster wrote:
> I am working on a small project to evaluate and execute unit conversion
> expressions. I started wondering whether it was possible to determine what
> the reverse conversion rules might blook like. ...
> The problem appears to lie in the domain of ( one to one ) function
> inversion or maybe equation solving.
It all depends on the scales. F and C are linear scales of measurements. So
to convert a value from one scale to another you need a linear function.
You can have logarithmic scales or more complex ones.
> I presume that such an algorithm has been implemented a hundred or so times,
> but my research is coming up dry.
> I'd appreciate it if someone could point me to some relevant material.
(it also contains a unit converter sample code)
Basically the approach is to use one scale where possible. That makes life
a lot easier, especially because it allows unit expressions evaluation.
(The pitfall is evaluation accuracy. As long as you are using
floating-point, that's is hardly an issue, but should you switch to fixed
point that would become a problem.)
Basically each scale entails a whole unit system. It is difficult to live
with that. One could say that was the reason why SI was invented. Foot,
lightyear and everything else can be represented in SI. So you just write;
1.5 * foot + 10.3 * meter -- This is fine
and the result is evaluated in SI units. You can get its numeric equivalent
in yards or furlongs if you want to. Also the factor is not an issue.
With C and F the picture becomes more complex. As I said above they
comprise scales of shifted units. Shifted units form a group for each value
of shift. Note a group, not a field, so they cannot be multiplied to
anything but a dimensionless value:
C / s -- Meaningless
If temperature delta was meant then it should have been
K / s
Units of different shifts cannot be added:
C + F -- Illegal, because ambiguous, what's the result's shift?
Logarithmic scales could be handled in a similar way.
For parsing infix expressions (with or without units) see:
Dmitry A. Kazakov
Return to the
Search the comp.compilers archives again.