Proposal: NumberBox enhancement for the decimal type
See original GitHub issueProposal
NumberBox
enhancement for the decimal
type
Summary
The NumberBox
is based on the double
type. It should be as easy to use the decimal
type instead.
Rationale
Many applications use the decimal
instead of the double
. If a property of type decimal
is used with compiled binding, a casting exception is thrown. With reflection-based binding, the value is always 0
.
- Decimals are often used with properties, and are needed to bind to UI elements, e.g. for money
Scope
Capability | Priority |
---|---|
This proposal will allow developers to bind the NumberBox to a decimal type |
Must |
Open Questions
Because a decimal
is not part of the Windows Runtime base data types there might not be that many options for this functionality. I was successfully in creating and using a converter to convert from decimal to double - however, this workaround shouldn’t be needed. Probably there’s a way for a built-in conversion, or other options?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
NumberBox - Fix Numeric and decimal length
Hi Sirs, Please let me know if there is options to fix the length of digits in dx number box. I want to...
Read more >DECIMAL type | Databricks on AWS
Represents numbers with a specified maximum precision and fixed scale. In this article: Syntax; Limits; Literals; Examples; Related. Syntax.
Read more >Blazor Numeric Textbox Overview - Documentation - Telerik
The Blazor Numeric Textbox component allows the user to enter decimal values and no text. The developer can control minimum, maximum values, steps...
Read more >Proposal to Add Decimal Floating Point Support to C++ ...
Unfortunately, decimal values cannot, in general, be represented accurately using binary floating points even when the decimal values only uses a few digits....
Read more >DECIMAL
The DECIMAL data type stores exact, fixed-point numbers. This type is used when it is important to preserve exact precision, for example, with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I asked for the same when we were first discussing the spec for the NumberBox
This is important for currency and other monetary information. However, you are correct that this isn’t possible because decimal is not in WinRT. (using type conversion like you suggested between double and decimal would be useless, the precision is already lost)
There are several sacrifices made in WinRT so it is compatible with the most languages/frameworks. I see this as one of them. If WinRT ever does get decimal support I would love to switch NumberBox to it. However, that would now be a breaking change that Microsoft likely wouldn’t support. So I think this should be closed:
The ship has already sailed I’m afraid.
@christiannagel
If precision isn’t an issue, I don’t think you need decimal. Just use Convert to go between double/decimal as you desire (assuming .net). Converting values is quite easy and I don’t think limits usability of NumberBox at all. In fact I could argue the opposite and say double is far more commonplace than decimal and switching to decimal hinders ease of use.
@mdtauk
That isn’t possible without changing to dynamic or object as the backing type for Value. This violates all sorts of API design principles. @christiannagel is correct and we would need another property of type decimal.