Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 2nd, 2004, 08:56 AM
Registered User
 
Join Date: Jul 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 300.2 - 300.1 = 0.0999999999999659?!

Hi people, I was printing the result of a simple arithmetic operation by Response.Write(300.2 - 300.1). Instead of giving me 0.1 as the result, it turned out to be 0.0999999999999659. Can anyone tell me why this is so? Any help will be very much appreciated.

 
Old July 6th, 2004, 06:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

with the reference of Mr.Chris post.

This should do the trick (just pass it your float & the number of decimal places you want)...

function FormatFloat(pFloat, pDp){
    var m = Math.pow(10, pDp);
    return parseInt(pFloat * m, 10) / m;
}

regards,








Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change dpi of image from 72 to 300 ? Snowby PHP FAQs 0 November 11th, 2006 07:26 AM
Make image from 72 dpi to 300 dpi. Snowby PHP How-To 0 November 11th, 2006 07:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.