Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Removing Decimals without Rounding Up or Down

Hey guys, In a character sheet I am designing, I need a way to remove decimals from my numbers without rounding up or down. Since the number in question can be positive or negative ceil() and floor() won't work for what I'm doing because rounding down a negative number is kinda rounding up (floor(-1.5) = -2).  I thought about using modulus (%) of the 2 numbers and subtracting the remainder but since the integers I am using are small integers ranging from -6 to 8, modulus also wont work because 2%3 is 2 and not 2/3. So if there is some way to simply cut off the decimal point that you guys have figured out, I would love to hear it! Thanks in advance.
1520732094
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
I'm assuming you're setting this with sheet workers. you can use ~~ (double tilde) to do this. It removes anything to the right of the decimal.
1520733628
GiGs
Pro
Sheet Author
API Scripter
If doing the operation in a sheet worker, you can use parseInt(number). If your concern is rounding correctly, you can use Math.round() in sheetworkers, or round() in roll20 dice expressions and autocalc fields. For reference, the  CSS Wizardry wiki page has a bunch of ways to simulate complicated math expressions using roll20 attributes. These all work in standard roll20 dice expressions.