Comments (2)
That's because your second block uses wrong currency, an empty one.
The NodaMoney library generally rounds amounts according to currency. Each currency specifies, how much decimal places it supports. For example Currency.FromCode("USD").DecimalDigits
returns 2
, because the smallest unit of US dollar is one cent.
In your example, you create an empty Money
structure, which has an empty Currency
structure. new Money().Currency.DecimalDigits
returns 0
. Therefore your amount gets rounded to 11.
from nodamoney.
Oh, that makes sense now. Thank you!
from nodamoney.
Related Issues (20)
- Newtonsoft Json serialization of default(Money) fails HOT 5
- Provide ExchangeRate JsonConverter out-of-the-box
- Addition/Subtraction with default(Money) should not throw InvalidCurrencyException HOT 1
- Serializing default Money property in a class (PR#70) HOT 6
- sample code doesn't work
- System.ArgumentOutOfRangeException when printing certain currencies
- Failing Tests - GivenIWantToParseImplicitCurrency HOT 2
- Money.ToString() fails for all currency with NotApplicable (-1) decimal places
- Reduce dependency on CultureInfo.Current and Thread Current culture.
- Why Currency is a struct, not class? HOT 3
- Currency code should be Enum, not a struct HOT 1
- Does NodaMoney run on Mono? What Dependencies are needed?
- Why a dependency on Newtonsoft.Json
- Does not have a strong name
- ExchangeRate how to? HOT 1
- Currency malformed on deserialization HOT 2
- Disable implicit conversion of decimal to money as static configuration option HOT 1
- Make Money a readonly struct
- Serialization/Deserialization net8 with Text.Json doesn't work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodamoney.