RadzenNumeric Format="0.##" is incorrectly handled as integer. #1590

Open
opened 2026-01-29 17:55:48 +00:00 by claunia · 4 comments
Owner

Originally created by @OndrejUzovic on GitHub (Feb 1, 2025).

The component RadzenNumeric works incorrectly in case the float number is formated like: 0.##.
The problem is the floating point is removed and then it is treated as integer.

Image

As shown in the video here are steps to reproduce the issue:

  1. Use the mouse to set the cursor before 0 and then type 1. (you get the number 10)
  2. Move the cursor at the end and type .55 (you get the number 10.55)
  3. Click outside RadzenNumeric.
  4. The floating number is changed to 155.

Here is the code to reproduce the issue:

<div class="rz-p-12 rz-text-align-center">
    <RadzenNumeric Format="0.##" @bind-Value=@value />
</div>

@code{
    float value;
}
Originally created by @OndrejUzovic on GitHub (Feb 1, 2025). The component RadzenNumeric works incorrectly in case the float number is formated like: 0.##. The problem is the floating point is removed and then it is treated as integer. ![Image](https://github.com/user-attachments/assets/24763b8c-1094-4dcd-901f-8ebf162f5102) As shown in the video here are steps to reproduce the issue: 1. Use the mouse to set the cursor before 0 and then type 1. (you get the number 10) 2. Move the cursor at the end and type .55 (you get the number 10.55) 3. Click outside RadzenNumeric. 4. **The floating number is changed to 155.** Here is the code to reproduce the issue: ``` <div class="rz-p-12 rz-text-align-center"> <RadzenNumeric Format="0.##" @bind-Value=@value /> </div> @code{ float value; } ```
Author
Owner

@enchev commented on GitHub (Feb 6, 2025):

The correct Format in my opinion should be 0.00 or n2: https://stackoverflow.com/a/6356381/245513

@enchev commented on GitHub (Feb 6, 2025): The correct Format in my opinion should be `0.00` or `n2`: https://stackoverflow.com/a/6356381/245513
Author
Owner

@OndrejUzovic commented on GitHub (Feb 6, 2025):

I think the the format 0.## is correct. It specifies there can be max 2 digits in the fractional part which are optional.
https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings
https://learn.microsoft.com/en-us/dotnet/api/system.single.tostring?view=net-9.0#system-single-tostring

@OndrejUzovic commented on GitHub (Feb 6, 2025): I think the the format `0.##` is correct. It specifies there can be max 2 digits in the fractional part which are optional. https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings https://learn.microsoft.com/en-us/dotnet/api/system.single.tostring?view=net-9.0#system-single-tostring
Author
Owner

@yourgurjeet commented on GitHub (Feb 6, 2025):

In my case it is working with ##.00 hope this help.

@yourgurjeet commented on GitHub (Feb 6, 2025): In my case it is working with ##.00 hope this help.
Author
Owner

@Cosmatevs commented on GitHub (May 8, 2025):

The problem is that . is not the decimal separator in your case. You probably need to type , instead, change the culture to any that uses a . as a decimal separator, or make a custom parser to handle both separators.

However, interpreting 10.55 as 155 is indeed a bug.
It's caused by the mysterious implementation of the RemoveNonNumericCharacters function. For some reason it removes the format string without #s from the input string – in this case 0..

@Cosmatevs commented on GitHub (May 8, 2025): The problem is that `.` is not the decimal separator in your case. You probably need to type `,` instead, change the culture to any that uses a `.` as a decimal separator, or make a custom parser to handle both separators. However, interpreting 10.55 as 155 is indeed a bug. It's caused by the mysterious implementation of the `RemoveNonNumericCharacters` function. For some reason it removes the format string without #s from the input string – in this case `0.`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1590