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

How to always round up

Explorer ,
Sep 22, 2017 Sep 22, 2017

Copy link to clipboard

Copied

So I'm useing this(thank you again to try67) to round to the nearest .25:

var a = this.getField("A").valueAsString;

if (a=="") event.value = "";

else {

    var v = Number(a);

    v = Math.round(v / 0.25) * 0.25;

    event.value = v;

}

But I need it to always round up, sometimes for instance if I have 5.60 it'll round to 5.50 when I need it to round to 5.75. How can I do this?

TOPICS
Create PDFs

Views

1.6K

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

correct answers 1 Correct answer

Explorer , Sep 22, 2017 Sep 22, 2017

Actually I figured it out, I just changed Math.round to Math.ceil

Votes

Translate

Translate
Explorer ,
Sep 22, 2017 Sep 22, 2017

Copy link to clipboard

Copied

Actually I figured it out, I just changed Math.round to Math.ceil

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 ,
Sep 23, 2017 Sep 23, 2017

Copy link to clipboard

Copied

LATEST

Math.round is for integer values only. One can use the util.printf() method for rounding the actual values of the field and the Number format with the optional decimal place specification for the number of decimal places if only the displayed result needs to be rounded. JavaScript by default stores numeric values as floating point values. There also user written JavaScript functions to perform floating point rounding.

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