Re: divide by zero processing transaction

2023-03-23 Thread John Wiegley
> "MM" == Martin Michlmayr  writes:

MM> Yeah, I thought "format" was for *display* precision only, so it doesn't
MM> make sense that this cuts off precision. Am I misunderstanding "format?"

This has been fixed in https://github.com/ledger/ledger/pull/2224. Good find!

John

-- 

--- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/m24jqbb9rr.fsf%40newartisans.com.


Re: divide by zero processing transaction

2023-03-04 Thread Martin Michlmayr
* Tavis Ormandy  [2023-03-04 15:42]:
> Yes, that is how I want it formatted - but I want it tracked
> internally at higher precision. I think that is a valid thing to want, right?

Yeah, I thought "format" was for *display* precision only, so it
doesn't make sense that this cuts off precision.  Am I
misunderstanding "format?"

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

-- 

--- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/ZAPpPJ2USeH9v5uR%40jirafa.cyrius.com.


Re: divide by zero processing transaction

2023-03-04 Thread Tavis Ormandy
On 2023-03-03, Ismael Bouya wrote:
> Hello!
>
> (Fri, Mar 03, 2023 at 04:25:06AM -) Tavis Ormandy :
>> Hello! I've managed to break my ledger file again :(
>> 
>> $ ledger bal
>> Error: Divide by zero
>> 
> You said that commodity FOO had a precision of 2 decimal digits, but in
> your entry you have 3, and the second one evaluates to 0 due to that
> precision.
>

Yes, that is how I want it formatted - but I want it tracked
internally at higher precision. I think that is a valid thing to want, right?

> Although formally correct with that change, on the spirit you prbably
> wanted that instead in your second transaction:
>
> 2023/01/03 * Transaction
> Assets:Brokerage  -1.211 FOO {$8.87} @ $16.79
> Assets:Brokerage  -0.003 FOO {$8.87} @ $16.79 ; Fractional shares 
> liquidated
> Assets:Checking  $20.38
> Income:Capital Gains
>
> (check with the ledger bal command to see the difference)

Oops, yes, you're right - it was just a fictional transaction to demonstrate 
the issue :)

Tavis.

-- 
 _o)$ lynx lock.cmpxchg8b.com
 /\\  _o)  _o)  $ finger tav...@sdf.org
_\_V _( ) _( )  @taviso

-- 

--- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/ttvotd%248t3%241%40ciao.gmane.io.


Re: divide by zero processing transaction

2023-03-03 Thread Ismael Bouya
Hello!

(Fri, Mar 03, 2023 at 04:25:06AM -) Tavis Ormandy :
> Hello! I've managed to break my ledger file again :(
> 
> $ ledger bal
> Error: Divide by zero
> 
> I minimized it down to this transaction (numbers changed for privacy):
> 
> commodity FOO
> format  1,000.00 FOO
> 
> 2022/12/31 * Opening Balances
> Assets:Brokerage  1.208 FOO @ $8.87
> Equity:Opening Balances
> 
> 2023/01/03 * Transaction
> Assets:Brokerage  -1.211 FOO @ $16.79
> Assets:Brokerage  -0.003 FOO @ $16.79 ; Fractional shares liquidated
> Assets:Checking  $20.38
> Income:Capital Gains

You said that commodity FOO had a precision of 2 decimal digits, but in
your entry you have 3, and the second one evaluates to 0 due to that
precision.

If you replace your format with
commodity FOO
  format  1,000.000 FOO
it starts working fine again.

Although formally correct with that change, on the spirit you prbably
wanted that instead in your second transaction:

2023/01/03 * Transaction
Assets:Brokerage  -1.211 FOO {$8.87} @ $16.79
Assets:Brokerage  -0.003 FOO {$8.87} @ $16.79 ; Fractional shares liquidated
Assets:Checking  $20.38
Income:Capital Gains

(check with the ledger bal command to see the difference)
-- 
Ismael

-- 

--- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/20230303131227.757qp2bi65ebmuee%40dilion.


signature.asc
Description: PGP signature


Re: divide by zero processing transaction

2023-03-03 Thread Ismael Bouya
Hello!

(Fri, Mar 03, 2023 at 04:25:06AM -) Tavis Ormandy :
> Hello! I've managed to break my ledger file again :(
> 
> $ ledger bal
> Error: Divide by zero
> 
> I minimized it down to this transaction (numbers changed for privacy):
> 
> commodity FOO
> format  1,000.00 FOO
> 
> 2022/12/31 * Opening Balances
> Assets:Brokerage  1.208 FOO @ $8.87
> Equity:Opening Balances
> 
> 2023/01/03 * Transaction
> Assets:Brokerage  -1.211 FOO @ $16.79
> Assets:Brokerage  -0.003 FOO @ $16.79 ; Fractional shares liquidated
> Assets:Checking  $20.38
> Income:Capital Gains

You said that commodity FOO had a precision of 2 decimal digits, but in
your entry you have 3, and the second one evaluates to 0 due to that
precision.

If you replace your format with
commodity FOO
  format  1,000.000 FOO
it starts working fine again.

Although formally correct with that change, on the spirit you prbably
wanted that instead in your second transaction:

2023/01/03 * Transaction
Assets:Brokerage  -1.211 FOO {$8.87} @ $16.79
Assets:Brokerage  -0.003 FOO {$8.87} @ $16.79 ; Fractional shares liquidated
Assets:Checking  $20.38
Income:Capital Gains

(check with the ledger bal command to see the difference)
-- 
Ismael

-- 

--- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/20230303131410.d3xydq6vff4o7hw4%40dilion.


divide by zero processing transaction

2023-03-02 Thread Tavis Ormandy
Hello! I've managed to break my ledger file again :(

$ ledger bal
Error: Divide by zero

I minimized it down to this transaction (numbers changed for privacy):

commodity FOO
format  1,000.00 FOO

2022/12/31 * Opening Balances
Assets:Brokerage  1.208 FOO @ $8.87
Equity:Opening Balances

2023/01/03 * Transaction
Assets:Brokerage  -1.211 FOO @ $16.79
Assets:Brokerage  -0.003 FOO @ $16.79 ; Fractional shares liquidated
Assets:Checking  $20.38
Income:Capital Gains

$ ledger --args-only -f zero.ldg bal
While parsing file "zero.ldg", line 12:
Error: Divide by zero
$ ledger --version
Ledger 3.3.0-20230208, the command-line accounting tool

I always seem to hit these edge cases :)

Thanks, Tavis.

-- 
 _o)$ lynx lock.cmpxchg8b.com
 /\\  _o)  _o)  $ finger tav...@sdf.org
_\_V _( ) _( )  @taviso

-- 

--- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ledger-cli/ttrsr2%24mtl%241%40ciao.gmane.io.