This is a migrated thread and some comments may be shown as answers.

RadNumericTextBox issue when entering more than 15 digits number

3 Answers 59 Views
Input
This is a migrated thread and some comments may be shown as answers.
Manoj
Top achievements
Rank 1
Manoj asked on 07 Aug 2014, 11:32 AM

I need to display the large number in exponential notation format.

When I enter more than 15 digit number which is "12345678901234567890" into the RadNumericTextBox

Value automatically gets rounded as 12345678901234560000.(Zero at the end) which is wrong.

But,
When I enter more than 21 digits number "1234567890123456789012"
then the value gets displayed as "1.234567890123457e+21" which is working perfectly

So the problem is in between the range 16 - 21 Digits. 

Please help to resolve this problem.


Using IE.9,Chrome,Firefox
VS2012
Telerik version : 2014.1.416.40


My Code
<telerik:RadNumericTextBox Width="100px" ID="txtTest" EmptyMessage="Test" ShowSpinButtons="false" DisplayText="" Type="Number"
                                runat="server" InvalidStyleDuration="100">
                                <NumberFormat AllowRounding="false" GroupSeparator="" DecimalDigits="15"   KeepNotRoundedValue="true" />
                                <ClientEvents OnKeyPress="keyPress" OnValueChanged="valueChanged"  />
</telerik:RadNumericTextBox>
 
Telerik.Web.UI.RadNumericTextBox.prototype._compileRegEx = function () {
                        var regexDecimalSeparator = this.get_numberFormat().DecimalSeparator == "." ? "\\." : this.get_numberFormat().DecimalSeparator;
                        this._acceptRegExp = new RegExp("[e0-9" + regexDecimalSeparator + this.get_numberFormat().NegativeSign + "]{1}");
                        this._rejectRegExp = new RegExp("[^e0-9" + regexDecimalSeparator + this.get_numberFormat().NegativeSign + "]{1}", "g");
                        this._decimalReplaceRegExp = new RegExp(regexDecimalSeparator, "g");
                    };
 
                    var orgNegativeSign = "";
                    function keyPress(sender, args) {
                        if (args.get_keyCode() == 45) {
                            orgNegativeSign = sender.get_numberFormat().NegativeSign;
                            sender.get_numberFormat().NegativeSign = "~";
                        }
                    }                
 
                     
                    function valueChanged(sender, args) {
                        if (orgNegativeSign != "") {
                            sender.get_numberFormat().NegativeSign = orgNegativeSign;
                            orgNegativeSign = "";
                        }                      
                    }

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 12 Aug 2014, 08:30 AM
Hi Manoj,

The RadNumericTextBox control supports numbers that are between -2^46 and 2^46. If you enter a number that is outside that range abnormalities in the behavior of the control could be observed.

This said, would you elaborate more on the scenario that you would like to implement? Are you performing calculations with a 21 digit number or it is only stored and used somewhere as is?

In case you do not need to perform calculations with the number and its length is fixed to 21 digits you could use a RadMaskedTextBox for the number.

Regards,
Viktor Tachev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
David
Top achievements
Rank 1
answered on 14 Dec 2016, 10:16 PM

Anyone know how to make 4.63e-10 work? this sample code allows for 4.63e10 but not a negative exponent.

Also, is allowing uppercase E as well possible?

0
Viktor Tachev
Telerik team
answered on 19 Dec 2016, 01:18 PM
Hello David,

Please note that the RadNumericTextBox does not allow the numbers to be displayed in scientific notation by default. This is because the input supports only numeric characters.

With that said, if you would like to show the numbers in scientific format I would recommend using RadTextBox or RadMaskedTextBox controls.


Regards,
Viktor Tachev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Input
Asked by
Manoj
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
David
Top achievements
Rank 1
Share this question
or