Jump to content
UBot Underground

Any javascript/math pros in here?


Recommended Posts

I'm doing keyword density reports for an article service that i'm running. I'm having trouble figuring out how to round a decimal to the 10th decimal place.

 

So i want

 

"flowers" - 0.40845070422535%

 

to be 0.4%

 

I tried using the Math.round function but I don't want it to round the numbers up or down, because it would show "0" for a value of 0.4 and I can't have that.

 

I just want to cut off the number at the 10th decimal place. Any help is greatly appreciated, been at this for 4 hours now! lol

Link to post
Share on other sites

Ok, i figured out my problem in case it can help anyone.

 

I used this function

 

number.toFixed(1)

 

Where "number" is the number you want to trim and the "1" means it chops off the number 1 position to the right of the decimal point.

 

So the number I wanted to trim was "0.73389"

 

I would use this...

 

0.73389.toFixed(1)

 

which would give 0.7

  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...