Greg Stark wrote:
> On Wed, Aug 19, 2009 at 8:24 PM, Alvaro
> Herrera<alvherre@commandprompt.com> wrote:
> >> [1] It doesn't correctly convert °C to °F or vv, that was one of the
> >> first things I tried.
> >
> > Seems it's easy to misuse it. You need tempF(x) and tempC notation for
> > converting absolute temperature differences:
> >
> > You have: tempF(212)
> > You want: tempC
> > 100
>
> That depends on whether you're converting a temperature or a
> temperature difference. If you want to know what a 100 degree C drop
> in temperature equates to in Fahrenheit the answer is not 212 but
> rather 180.
Right -- and there's a different interface for that.
You have: 100 degC
You want: degF
* 180
/ 0.0055555556
> I think it would be useful to have a builtin data type which contained
> a float and an opaque text unit. It could support linear operations
> like +, -, and sum() by just throwing an error if the units didn't
> match.
This sounds very much like Martijn's tagged types.
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.