• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

decimal part

New Here ,
Aug 28, 2008 Aug 28, 2008

Copy link to clipboard

Copied

if I have this number (or a var) but I only want to keep what is left after the period for example:
1.28 want to keep only .28
23.43 =>.43
45.00=>.00

how do I do that?
Thanks
TOPICS
ActionScript

Views

530

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 29, 2008 Aug 29, 2008

Copy link to clipboard

Copied

If formatting is not an object, you might use this:

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 29, 2008 Aug 29, 2008

Copy link to clipboard

Copied

var valStr:String = String(23.43);

trace(valStr.substr(valStr.indexOf(".")));
// return .43

trace(valStr.substr(valStr.indexOf(".")+1));
// return 43


use this code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 16, 2008 Oct 16, 2008

Copy link to clipboard

Copied

What if I have a number like this .2006164410284421208 and I want to display it as 20.06. I know if I do (Math.round(Percentage*100)) I get 20, but how do I get the 2 numbers after the decimal point?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 16, 2008 Oct 16, 2008

Copy link to clipboard

Copied

(Percentage*100).toFixed(2)


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 16, 2008 Oct 16, 2008

Copy link to clipboard

Copied

LATEST
Perfect! Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 16, 2008 Oct 16, 2008

Copy link to clipboard

Copied

var n:Number=12345.67890;
trace(Math.floor((n-Math.floor(n))*100)/100);

would give 0.67


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines