Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript 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 30th, 2003, 01:05 AM
Authorized User
 
Join Date: Jul 2003
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to keep two digit after float number?

I have a variable,
  var s;
after some calculate,s=10.04999999
I want to keep two digit after s,make s=10.05
How to do it?

 
Old July 30th, 2003, 01:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

s = (Math.round((s)*100)/100);



======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
Extract a digit from specified position sektor Visual Basic 2005 Basics 10 June 9th, 2008 05:05 PM
float not working mister_mister CSS Cascading Style Sheets 1 March 11th, 2008 05:00 PM
TAPI 3.0 : Problem in Digit Detection Qaisar Visual C++ 0 March 10th, 2006 09:54 PM
Float precision nulogix C++ Programming 1 November 10th, 2005 09:53 PM
7 Digit number jemacc SQL Server 2000 3 April 4th, 2004 01:02 AM





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