RadNumericTextBox issue when entering more than 15 digits number

4 posts, 0 answers
  1. Manoj
    Manoj avatar
    26 posts
    Member since:
    Feb 2012

    Posted 07 Aug 2014 Link to this post

    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.

    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
    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.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 = "";
  2. Viktor Tachev
    Viktor Tachev avatar
    2187 posts

    Posted 12 Aug 2014 Link to this post

    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.

    Viktor Tachev

    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.

  3. David
    David  avatar
    5 posts
    Member since:
    Nov 2010

    Posted 14 Dec 2016 Link to this post

    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?

  4. Viktor Tachev
    Viktor Tachev avatar
    2187 posts

    Posted 19 Dec 2016 Link to this post

    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.

    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.
Back to Top