1g or 1G gives a BigInteger and here the suffix is required to not get an
Integer. Using 1.0g/G for BD seems a natural extension.

Most expressions involving both BI and BD give the results you'd expect so
I believe it was thought at the time that using the same suffix was
sufficient, with toBigInteger() and toBigDecimal() allowing you to swap
between them if really needed.

Do you have a particular scenario that you find that the current
conventions limit you, or are you just noticing the trade-offs that were
made in this case and making sure you fully understand them?

Paul.


On Wed, Aug 20, 2025 at 2:13 AM OCsite <o...@ocs.cz> wrote:

> Hi there,
>
> I've just bumped into
> https://groovy-lang.org/syntax.html#_number_type_suffixes, namely, to
>
> BigDecimal
>
> G or g
>
> which seems rather pointless to me. When one enters a decimal number
> (e.g., 1.0), it's a BD anyway, suffix or not. On the other hand, there
> seems to be no suffix which would allow to write e.g., just 1s (s for
> *something*) creating a 1 BD, which would make some sense, like e.g., 1f
> for float does.
>
> What do I overlook? What's the point of the BD g/G suffix, and why there's
> no suffix which would work without a decimal point (or exponent)?
>
> Thanks,
> OC
>
>

Reply via email to