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

RadNumericTextBox 3.97 = 3.9699999999999997

3 Answers 61 Views
Input
This is a migrated thread and some comments may be shown as answers.
Douglas R.
Top achievements
Rank 1
Douglas R. asked on 28 Sep 2009, 02:44 PM

Go to the demo page at http://demos.telerik.com/aspnet-ajax/input/examples/radnumerictextbox/firstlook/defaultvb.aspx
Change decimal digits to 2.
Enter 3.97 in the text box.
Value is displayed as 3.9699999999999997

This is also occuring with control.set_value(3.97)

Has this been fixed?

Thanks ... Douglas

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Sep 2009, 12:03 PM
Hi Douglas,

I found the following forum link which discusses on are removing digits after two places from the decimal point using javascript. Probably this can help you out:
Rounded value after 2 decimal digit

-Princy.
0
Martin
Telerik team
answered on 01 Oct 2009, 08:45 AM
Hello Douglas and  Princy,

It seems that this issue is caused by the way Javascript engine calculates some decimal numbers. For example you can try this code:

function pageLoad(sender,atgs) 
            { 
                alert(2 + 0.97); 
            } 

Our devs built a temporary workaround for this erroneous behavior. To implement it you should:

  1.  Add the following code to the markup of your page:

<script type="text/javascript" src="inputRoundingFix.js"
</script> 

  2.  Add the needed Javascript file into your project folder. You can find the file attached.

We will imlpement this functionality in the next internal build which will be available for download from the latest internal build section in the next few days.
Alternatively you could wait for the official release of RadControls for ASP.NET AJAX - Q3 2009 which is due for the first week of November.

I hope this helps.

Regards,
Martin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Douglas R.
Top achievements
Rank 1
answered on 11 Nov 2009, 08:50 PM
I waited for Q3 2009 and while it does fix this issue, addtional issues have arisen (50% CPU utilization, focus not working, can't scroll pages, etc).  So, I went back to Q2 2009 and tried the included script -- works great (just have to include it near the /form tag).
Tags
Input
Asked by
Douglas R.
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Martin
Telerik team
Douglas R.
Top achievements
Rank 1
Share this question
or