-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Maximum integer part and scale #75
Comments
So I'm uncertain what action your are looking to be taken? |
There is no mention of border conditions in the documentation except AmountTooLargeException which is confusing because the library does not work correctly even at smaller scale and without num. First of all, I was looking for an answer to the question at what point does the library stopping working in my test, assuming that I missed something. |
And it is not Fixed: problem, I just wrote similar test. |
@nesquikm so I ran your unit tests and they all pass? |
What is your test environment? |
As I mention before, I offered Fixed.parse() as a fix for Money.parseWithCurrency() bug. You just added test for Fixed.parse(), so it should pass :) |
sorry I missed that.
So we need the same set of unit tests for Money?
…On Mon, Apr 17, 2023 at 5:40 AM nesquikm ***@***.***> wrote:
As I mention before, I offered Fixed.parse() as a fix for
Money.parseWithCurrency() bug. You just added test for Fixed.parse()
<68e8c5d>,
so it's should pass :)
—
Reply to this email directly, view it on GitHub
<#75 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG32OA5R44FSD7S3GBXOEDXBRDMRANCNFSM6AAAAAAVSJADLU>
.
You are receiving this because you commented.Message ID: <onepub-dev/money
.***@***.***>
|
Yeah, there is test for money (also you can find it in the first comment), try to increase maxScale or maxInts to see the problem. |
do you have a specific requirement? |
I've documented the limits here: and I've opened an enhancement request to increase the limits. |
I just found that Money.fromJson and toJson have similar problems (they use toInt()). So I added some tests and updated my package that fixes all of these problems: https://pub.dev/packages/money2_fixer For context you can run example:
|
So instead of doing that raise a pr.
Unnecessary bifurcation of dary packages is not helping the dart community.
…On Fri, 14 Feb 2025, 7:34 pm nesquikm, ***@***.***> wrote:
I just found that Money.fromJson and toJson have similar problems (they
use toInt()). So I added some tests and updated my package that fixes all
of these problems: https://pub.dev/packages/money2_fixer
For context you can run example
<https://github.com/nesquikm/money2_fixer/blob/main/example/money2_improver_example.dart>
:
Test with: integers: 3, decimals: 18
String: 999.999999999999999999
Pattern: 0.################## S
Parse and format:
with Money.parse: 999.999999999999999999 SV
with improved method: 999.999999999999999999 SV
To and from json:
parsing, integer part: 999, decimal part: 999999999999999999
to and from Money.json: integer part: 999 decimal part: 999999999999999999
to and from json improved: integer part: 999 decimal part: 999999999999999999
Test with: integers: 3, decimals: 19
String: 999.9999999999999999999
Pattern: 0.################### S
Parse and format:
with Money.parse: -842.8297329635842064385 SV
with improved method: 999.9999999999999999999 SV
To and from json:
parsing, integer part: 999, decimal part: 9999999999999999999
to and from Money.json: integer part: 999 decimal part: 9223372036854775807
to and from json improved: integer part: 999 decimal part: 9999999999999999999
Test with: integers: 19, decimals: 3
String: 9999999999999999999.999
Pattern: 0.### S
Parse and format:
with Money.parse: 9223372036854775807.999 SV
with improved method: 9999999999999999999.999 SV
To and from json:
parsing, integer part: 9999999999999999999, decimal part: 999
to and from Money.json: integer part: 9223372036854775807 decimal part: 999
to and from json improved: integer part: 9999999999999999999 decimal part: 999
—
Reply to this email directly, view it on GitHub
<#75 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG32OCMEUX3F6MTCQ5KRWL2PWTABAVCNFSM6AAAAABXECVZKGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNJYGU4TMOJTGU>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
[image: nesquikm]*nesquikm* left a comment (onepub-dev/money.dart#75)
<#75 (comment)>
I just found that Money.fromJson and toJson have similar problems (they
use toInt()). So I added some tests and updated my package that fixes all
of these problems: https://pub.dev/packages/money2_fixer
For context you can run example
<https://github.com/nesquikm/money2_fixer/blob/main/example/money2_improver_example.dart>
:
Test with: integers: 3, decimals: 18
String: 999.999999999999999999
Pattern: 0.################## S
Parse and format:
with Money.parse: 999.999999999999999999 SV
with improved method: 999.999999999999999999 SV
To and from json:
parsing, integer part: 999, decimal part: 999999999999999999
to and from Money.json: integer part: 999 decimal part: 999999999999999999
to and from json improved: integer part: 999 decimal part: 999999999999999999
Test with: integers: 3, decimals: 19
String: 999.9999999999999999999
Pattern: 0.################### S
Parse and format:
with Money.parse: -842.8297329635842064385 SV
with improved method: 999.9999999999999999999 SV
To and from json:
parsing, integer part: 999, decimal part: 9999999999999999999
to and from Money.json: integer part: 999 decimal part: 9223372036854775807
to and from json improved: integer part: 999 decimal part: 9999999999999999999
Test with: integers: 19, decimals: 3
String: 9999999999999999999.999
Pattern: 0.### S
Parse and format:
with Money.parse: 9223372036854775807.999 SV
with improved method: 9999999999999999999.999 SV
To and from json:
parsing, integer part: 9999999999999999999, decimal part: 999
to and from Money.json: integer part: 9223372036854775807 decimal part: 999
to and from json improved: integer part: 9999999999999999999 decimal part: 999
—
Reply to this email directly, view it on GitHub
<#75 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG32OCMEUX3F6MTCQ5KRWL2PWTABAVCNFSM6AAAAABXECVZKGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNJYGU4TMOJTGU>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
You are of course right, I will try to make a PR as soon as I have time. |
can I suggest that we merge the two projects and I add you as a contributor to money2 and then mark money2_fixer as deprecated. I'm always happy to have help. |
Yes, of course. It would probably be nice to add tests from money2_fixer too. |
That would be great!
…On Sat, 15 Feb 2025, 7:33 pm nesquikm, ***@***.***> wrote:
Yes, of course. It would probably be nice to add tests from money2_fixer
too.
—
Reply to this email directly, view it on GitHub
<#75 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG32OGGE4VS7JJKRI7KXQD2P33UPAVCNFSM6AAAAABXECVZKGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNRQHAYTKMRTGI>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
[image: nesquikm]*nesquikm* left a comment (onepub-dev/money.dart#75)
<#75 (comment)>
Yes, of course. It would probably be nice to add tests from money2_fixer
too.
—
Reply to this email directly, view it on GitHub
<#75 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAG32OGGE4VS7JJKRI7KXQD2P33UPAVCNFSM6AAAAABXECVZKGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNRQHAYTKMRTGI>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
So, I created two PR: But I think we should eliminate all the rest toInt()/fromInt(), and check math operations for big int support. |
I couldn't find any mention of any restrictions, but as far as I can see the integer and fractional parts are represented by the BigInt. However, the simple test below breaks when maxScale>18 or maxInts>18:
The text was updated successfully, but these errors were encountered: