Re: Add numeric_trim(numeric)

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Marko Tiikkaja <marko(at)joh(dot)to>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add numeric_trim(numeric)
Date: 2015-12-26 20:44:51
Message-ID: CAFj8pRBW73THWPN8aX0CpXt_hAzk7yvd_tGdfRaXoLzg0yToGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

2015-11-19 3:58 GMT+01:00 Marko Tiikkaja <marko(at)joh(dot)to>:

> Hi,
>
> Here's a patch for the second function suggested in
> 5643125E(dot)1030605(at)joh(dot)to(dot) This is my first patch trying to do anything
> with numerics, so please be gentle. I'm sure it's full of stupid.
>
> January's commit fest, feedback welcome, yada yada..
>

I am looking on this patch and I don't understand to formula

dscale = (ndigits - arg.weight - 1) * DEC_DIGITS;

the following rule is valid

DEC_DIGITS * ndigits >= dscale + arg.weight + 1

so dscale should be calculated like

dscale <= DEC_DIGITS * ndigits - arg.weight - 1

?

but your formula is correct and working. Can you explain it?

Regards

Pavel

>
>
> .m
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2015-12-27 00:04:12 Re: 9.5rc1 brin_summarize_new_values
Previous Message Joe Conway 2015-12-26 20:39:23 Re: exposing pg_controldata and pg_config as functions