Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > **Newbie Need Help** with Math.object

Reply
Thread Tools

**Newbie Need Help** with Math.object

 
 
Dobie
Guest
Posts: n/a
 
      09-21-2003
I need to know if there's a Math.object that will
make a # such as 123.4567 and round it to the
nearest 1/100. To make the # be 123.46. I have
seen Math.floor, Math.round, Math.random and
other objects. But none will do what I need.
Help ???
The only reason I need to do this is because I have
a list of products with their prices. And when you
enter the quantity amount, that # gets multiplied
by the price. And on some of the prices, a long
integer gets returned. And it would be nice to have
a price of $123.46 instead of $123.4567.

TIA,
Dobie
 
Reply With Quote
 
 
 
 
DU
Guest
Posts: n/a
 
      09-21-2003
Dobie wrote:
> I need to know if there's a Math.object that will
> make a # such as 123.4567 and round it to the
> nearest 1/100. To make the # be 123.46. I have
> seen Math.floor, Math.round, Math.random and
> other objects. But none will do what I need.
> Help ???
> The only reason I need to do this is because I have
> a list of products with their prices. And when you
> enter the quantity amount, that # gets multiplied
> by the price. And on some of the prices, a long
> integer gets returned. And it would be nice to have
> a price of $123.46 instead of $123.4567.
>
> TIA,
> Dobie


Best is to always try to find answers by yourself in documentation and
references or in archives posts and threads of this newsgroup. Your
question was answered before. There is a FAQENTRY on this

http://jibbering.com/faq/#FAQ4_6

Also:

toPrecision([precision])

Parameters: precision
An integer specifying the number of digits after the decimal point.

http://devedge.netscape.com/library/...r.html#1201389



toFixed
Returns a string representing the Number object in fixed-point notation.

Syntax
toFixed([fractionDigits])

Parameters
fractionDigits

An integer specifying the number of digits after the decimal point.
Defaults to zero.
http://devedge.netscape.com/library/...r.html#1200964

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to "shred" hardive..need software. Xeno Chauvin Computer Support 4 03-13-2005 01:26 PM
Need help with need to Force Garbage Collect John Java 1 08-19-2004 03:32 PM
Need help! I need to add lead zeros to a textbox Teep ASP .Net 2 06-21-2004 01:04 PM
Please help!!! Need datagrid selection to fill textboxes...Need quick!! TN Bella ASP .Net 1 06-18-2004 01:31 AM
Need to compare Photos to DVD software - Need Help? Bob Digital Photography 4 02-04-2004 02:13 AM



Advertisments