summaryrefslogtreecommitdiff
path: root/src/amount.cc
Commit message (Collapse)AuthorAgeFilesLines
* Avoid ctype abuse.Taylor R Campbell2024-08-061-3/+4
| | | | | fix https://github.com/ledger/ledger/issues/2338 fix https://github.com/ledger/ledger/issues/2340
* Fix copy on write for amount_t::in_place_roundtoMax Nikulin2024-08-061-8/+1
| | | | | | | | | | | | - Copy amount quantity before rounding. - Fix `amount_t::roundto(int)`. - Transform `balance/testRound` into `balance/testRoundto`. It was a mix of `round` and `roundto` operation with unclear purpose and was relying on `in_place_roundto` behavior modifying all copies. There is no unit tests for balance `round` and `unround` any more. Closes #2362
* Fix denominator of roundto resultMax Nikulin2024-08-051-2/+39
| | | | | | | | | | | | | | | | | | Multiprecision rational created from a double value may have large power of 2 denominator since fractional decimal numbers can not be represented as binary floating point numbers. It leads to failed assertion when result is compared to a value converted directly from strings. Use integer multiprecision arithmetics to round numbers to ensure proper denominator. Inspired by python gmpy2 package <https://github.com/aleaxit/gmpy/blob/3e4564ae9d/src/gmpy2_mpq_misc.c#L315> The change makes `roundto` symmetric for positive/negative arguments. Halves are rounded to nearest even. Rounded away from zero are discussed in #1663 and it may be achieved with minimal modification. - See #2329 - Closes #1983
* Refactor basic_flags_t to ledger::flags::basic_tAlexis Hildebrandt2023-04-121-1/+1
|
* Update copyright yearAlexis Hildebrandt2023-02-021-1/+1
| | | | [skip ci]
* Update copyright statement for 2022Alexis Hildebrandt2022-07-021-1/+1
|
* Avoid dereferencing null pointerKunht Kun2022-03-121-1/+2
| | | | | | | Here `comm` could be a null pointer (the new test regress/2057 shows such a case). So test it before dereferencing to avoid segfault. Re: #2057
* Use correct int return type for stream input operationskanreki2021-12-081-4/+4
| | | | | | | | This makes it safe to compare results to -1 to indicate EOF, regardless of whether char is considered signed or unsigned; and so eliminates compiler warnings on platforms such as ARM. Fixes bug #2058.
* Fix --time-colon for negative time amountsRafael Ascensão2021-09-271-7/+3
| | | | | | | | | | | | | | | While the current formula works for positive numbers, negative numbers are incorrectly represented. One of the issues comes from the fact that floor(x) < x for every x. `amount_t precision` will always be a non negative number and the code that attempts to fix the issue for negative number will never run. If we truncate the number instead, the current formula works for both positive and negative numbers without making negative numbers a corner case. So let's do that. Signed-off-by: Rafael Ascensão <rafa.almas@gmail.com>
* Fix amount tokenizer re: embedded minus sign.Donald Lam2021-05-021-2/+9
| | | | | An amount may have a (single) leading minus sign, but none after that. Bug #2001 (and #1809).
* Fix typos in commentsMartin Michlmayr2020-05-211-2/+2
|
* Don't attempt to invert a value if it's already zero (#1703)John Wiegley2019-01-111-1/+3
|
* [misc] Update year in copyright notice to 2017Alexis Hildebrandt2018-01-271-1/+1
| | | | [ci skip]
* The "format" directive for commodities now disables "style observation"John Wiegley2018-01-011-1/+3
|
* [misc] Update year in copyright notice to 2017Alexis Hildebrandt2017-01-051-1/+1
| | | | [ci skip]
* [misc] Update year in copyright notice to 2016Alexis Hildebrandt2016-01-021-1/+1
| | | | [ci skip]
* [ledger] Remove --cache optionAlexis Hildebrandt2015-02-181-79/+0
| | | | and all boost serialisation related code.
* Bump copyright notice to 2015Alexis Hildebrandt2014-12-271-1/+1
| | | | | | The following script makes it a no-brainer: % NEXT_YEAR=2015; ag -l 'Copyright.*Wiegley' \ | xargs sed -i '' -e "s/\(Copyright.*\)-20[0-9]\{2\}/\1-${NEXT_YEAR}/"
* Unify debugging categoriesMartin Michlmayr2014-07-011-4/+4
| | | | | Debugging categories follow the filename, which in this case is singular (rather than plural) "account" and "amount".
* Bump copyright information to 2014Alexis Hildebrandt2014-02-021-1/+1
|
* Apply --time-colon option only to time commoditiesAlexis Hildebrandt2013-09-071-5/+5
| | | | See #989
* Resolve new compiler warnings from ClangJohn Wiegley2013-05-191-0/+2
|
* fix ledger xml output, remove ledger json commandJohann Klähn2013-03-081-5/+3
| | | | | | | | | | | | As the format used by property trees to represent valid JSON and that for valid XML is too different and given that there are more requests for valid XML output I decided to pursue a quick fix and remove the json command in favor of a working xml command. See bug #782, #909, recent discussion on mailing list. JSON support is postponed until I or someone else finds time to work on this or the python bindings are more stable.
* Bump copyright information to 2013John Wiegley2013-02-181-1/+1
|
* Bug 634 Added roundto function, optimized floor and ceilingCraig Earls2013-01-301-14/+15
| | | | Fixes Bug634 by adding roundto(amount, places).
* Merge pull request #107 from afh/pull/time_colonJohn Wiegley2013-01-291-2/+21
|\ | | | | Add --time-colon option
| * Add --time-colon optionAlexis Hildebrandt2012-11-101-2/+21
| | | | | | | | | | | | | | | | | | The --time-colon option will display the value for a seconds based commodity as real hours and minutes. For example 8100 seconds by default will be displayed as 2.25 whereas with the --time-colon option they will be displayed as 2:15.
* | whitespace cleanupJohann Klähn2013-01-161-1/+1
|/
* Bug 634 and 488, Corrected behavior of floor, and added ceilingCraig Earls2012-10-251-3/+20
| | | | This is only a partial fix for 634, since rounding is not fixed.
* Changed all ASSERTS_ON -> !NO_ASSERTSJohn Wiegley2012-05-201-1/+1
|
* Converted the Ledger build system to use CMakeJohn Wiegley2012-05-201-7/+7
|
* Switched to Boost.PropertyTree for XML generationJohn Wiegley2012-05-181-7/+5
|
* Switch to using Boost.FormatJohn Wiegley2012-05-141-6/+6
|
* Whitespace fixJohn Wiegley2012-03-301-4/+4
|
* Never price commodities using annotated commoditiesJohn Wiegley2012-03-301-3/+3
|
* Improved some error messagesJohn Wiegley2012-03-291-10/+8
|
* Always call TRACE_CTOR at the end of constructorsJohn Wiegley2012-03-201-5/+5
|
* Tighten up argument passing related to fn_market()John Wiegley2012-03-111-12/+7
|
* Added syntactic sugar for lot pricing: {{$500.00}}John Wiegley2012-03-101-4/+8
|
* Added amount_t::commodity_ptr()John Wiegley2012-03-091-2/+7
|
* Made amount_t::price return an optional<amount_t>John Wiegley2012-03-071-2/+2
|
* Corrected several compile and link problemsJohn Wiegley2012-03-061-0/+2
|
* Changed the category of a few DEBUG statementsJohn Wiegley2012-03-061-4/+4
|
* Use unique_ptr instead of std::auto_ptrJohn Wiegley2012-03-051-2/+2
|
* All tests are working again but oneJohn Wiegley2012-03-051-6/+3
|
* Increased file copyrights to 2012John Wiegley2012-02-291-1/+1
|
* Fixed many Clang type conversion warnings with static_castJohn Wiegley2012-02-171-4/+8
|
* Fixes for variable shadowing (5/28)John Wiegley2012-02-171-3/+3
|
* Fixes for variable shadowing (4/28)John Wiegley2012-02-171-4/+4
|
* Fixes for variable shadowing (3/28)John Wiegley2012-02-171-4/+4
|