Is it possible to abbreviate very large numbers? Using megs (M), kilos (K), etc? (EOM)

34 views
Skip to first unread message

Felipe Mica

unread,
Sep 11, 2021, 6:55:28 PMSep 11
to Ledger
Thank you.

Martin Michlmayr

unread,
Sep 11, 2021, 8:48:09 PMSep 11
to ledge...@googlegroups.com
Not that I'm aware of, but I'm not 100% sure.

--
Martin Michlmayr
https://www.cyrius.com/

Felipe Mica

unread,
Sep 11, 2021, 9:09:17 PMSep 11
to Ledger
When working with cryptocurrencies, something like that:

203,320,244,020,398,298 DOGE can be very common.

It would be useful an option like --shorten-huge-numbers and change this to:

203,320.24T DOGE

Or maybe the solution could be create another commodity and use the C directive as you said in the other email.

Thank you for all your replies.

Fergus Cameron

unread,
Sep 12, 2021, 9:45:48 AMSep 12
to ledge...@googlegroups.com
You MIGHT use a commodity. For example, M_USD for millions of dollars ... that's not a problem I face :-) ... and I realize it's not a direct correlation to your question but maybe it's useful in some context

--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ledger-cli/YT1OQ7SldiGXI44c%40jirafa.cyrius.com.

Colin Dean

unread,
Sep 12, 2021, 8:04:54 PMSep 12
to Ledger
You should be able to use commodity equivalencies to solve this problem to a degree, but it won't be automatic based on the magnitude in context, only whatever you set as the exchange, I think.

Felipe Mica

unread,
Sep 13, 2021, 11:54:18 AMSep 13
to Ledger
Thank you guys. I could manage that with this:

commodity BTC
  note Bitcoin
  format 1,000.00000000 BTC

commodity bit
  format 1,000.00 bit

commodity SAT
  note Satoshis
  format 1,000 SAT

C 1.00000000 BTC = 100,000,000 SAT
C 1.00 bit = 100 SAT
C 1.00000000 BTC = 1,000,000.00 bit


John Wiegley

unread,
Sep 15, 2021, 1:14:52 AMSep 15
to Colin Dean, Ledger
>>>>> "CD" == Colin Dean <c...@cad.cx> writes:

CD> You should be able to use commodity equivalencies to solve this problem to
CD> a degree, but it won't be automatic based on the magnitude in context,
CD> only whatever you set as the exchange, I think.

Actually, it should adjust the magnitude dependent on context, this is how the
automated conversions to hours, minutes and seconds work for time values. Just
use something like this:

C 1 KB = 1000 B
C 1 MB = 1000 KB
C 1 GB = 1000 MB
etc.

It should then pick whichever one can be reported at a value of 1 or more.

John

Felipe Mica

unread,
Sep 17, 2021, 11:45:16 AMSep 17
to Ledger
This works for a while:

C 1.00000000 BTC = 100,000,000 SAT
C 1.00 bit = 100 SAT
C 1.00000000 BTC = 1,000,000.00 bit

But then the ledger-cli made a mess of commodity conversions. Even if I use the option --exchange BRL if I put this equivalence lines the ledger-cli just ignores the conversion price I put.

Take this file as an example:

P 2021-09-01 00:00:00 BTC 256103,91738800 R$

2021-09-17 * Opening Balance
    My Wallet                             1,00000000 BTC
    Equity:Opening Balances


When I run:

ledger -f draft.ledger bal --exchange=R$

I get the expected result:

           R$-256104  Equity:Opening Balances
            R$256104  My Wallet
--------------------
                   0

But if I add the equivalence of the commodity BTC, as follow:

C 1.00000000 BTC = 100,000,000 SAT
C 1.00 bit = 100 SAT
C 1.00000000 BTC = 1,000,000.00 bit

P 2021-09-01 00:00:00 BTC 256103,91738800 R$

2021-09-17 * Opening Balance
    My Wallet                             1,00000000 BTC
    Equity:Opening Balances


The result of:

ledger -f draft.ledger bal --exchange=R$

is surprisingly:

     -1,00000000 BTC  Equity:Opening Balances
      1,00000000 BTC  My Wallet
--------------------
                   0

The ledger-cli starts to ignore the conversion.

It seems a bug behavior.

John Wiegley

unread,
Sep 17, 2021, 1:24:26 PMSep 17
to Felipe Mica, Ledger
>>>>> "FM" == Felipe Mica <mica...@gmail.com> writes:

FM> The ledger-cli starts to ignore the conversion.
FM> It seems a bug behavior.

I agree that this sounds like a bug. --exchange should always take priority,
if a conversion exists into your desired display commodity.

John
Reply all
Reply to author
Forward
0 new messages