Skip to main content
Participating Frequently
September 30, 2021
Answered

Can a number always be rounded down to integer level

  • September 30, 2021
  • 1 reply
  • 255 views

I have tried math.floor and math,round and both round up if decimal is .5 or highter. And yes for you feelow DMs, this is a D&D form

 

Formula I am trying to work with.

 

var a = this.getField("Dex_Raw").value

var b = (a-10)/2

event.value = math round(b) 

 

if a=11 I get a result of 1 because b=-5

I need event value on 11 to be 0

Same with any odd number.

Thoughts ?  I tried googling it all morning and no one seemed to have a solid answer that did not involve setting up scripts, witch I am not sure you can do in adone acro

 

This topic has been closed for replies.
Correct answer Nesa Nurani

Use:  Math.round() or Math.floor()

 

EDIT:

Try this:

var a = Number(this.getField("Dex_Raw").value);
var b = (a-10)/2
if(this.getField("Dex_Raw").valueAsString == "")
event.value = "";
else
event.value = Math.floor(b);

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
September 30, 2021

Use:  Math.round() or Math.floor()

 

EDIT:

Try this:

var a = Number(this.getField("Dex_Raw").value);
var b = (a-10)/2
if(this.getField("Dex_Raw").valueAsString == "")
event.value = "";
else
event.value = Math.floor(b);