# Verify number of decimal places

**URL:** <https://community.glideapps.com/t/verify-number-of-decimal-places/62884>\
**Category:** Ask for Help\
**Created:** [June 17, 2023, 11:17pm UTC](https://community.glideapps.com/t/verify-number-of-decimal-places/62884 "2023-06-17T23:17:43Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![pipharvester](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pipharvester/32/61697_2.png) [@pipharvester](https://community.glideapps.com/u/pipharvester)\
**Post date:** [June 17, 2023, 11:17pm UTC](https://community.glideapps.com/t/verify-number-of-decimal-places/62884/1 "2023-06-17T23:17:43Z")

</div>

I have a cell where I need to determine the number of decimals (2 digit or 4 digit) in the price that is being placed in that cell in order that I may divide by 100 or 1000 in order to complete the formula and return the proper value. All formula logic is in the google sheets cell…  
Thanks is advance!  
Jerry

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [June 18, 2023, 2:21am UTC](https://community.glideapps.com/t/verify-number-of-decimal-places/62884/2 "2023-06-18T02:21:45Z")

</div>

You can use a Math column with the Round formula to control the number of decimals, and then write the rounded value.

Have you considered moving your spreadsheet formulas to the Glide Data Editor?

---

<div class="post-metadata">

**Author:** ![pipharvester](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pipharvester/32/61697_2.png) [@pipharvester](https://community.glideapps.com/u/pipharvester)\
**Post date:** [June 18, 2023, 3:09am UTC](https://community.glideapps.com/t/verify-number-of-decimal-places/62884/3 "2023-06-18T03:09:37Z")

</div>

Thanks for the reply. I am not needing to round them but rather determine whether they are 2 digit or 4 digit and then the calculation changes depending on that result. I have not found how to do the same level of calculations using the Data Editor…would be glad to do that…

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [June 18, 2023, 3:43am UTC](https://community.glideapps.com/t/verify-number-of-decimal-places/62884/4 "2023-06-18T03:43:29Z")

</div>

Can you share more about the calculations that are done in the spreadsheet?  
Maybe I can help you with that.

---

<div class="post-metadata">

**Author:** ![nathanaelb](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nathanaelb/32/43079_2.png) [@nathanaelb](https://community.glideapps.com/u/nathanaelb)\
**Post date:** [June 18, 2023, 6:18pm UTC](https://community.glideapps.com/t/verify-number-of-decimal-places/62884/5 "2023-06-18T18:18:25Z")

</div>

Maybe you could assume they all have 4? (1.23 = 1.2300)

Or as Darren suggested, see if you can adapt your approach slightly, because it would be surprising that your math operations depend on 2 trailing zeros.

---

<div class="post-metadata">

**Author:** ![pipharvester](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pipharvester/32/61697_2.png) [@pipharvester](https://community.glideapps.com/u/pipharvester)\
**Post date:** [June 18, 2023, 8:03pm UTC](https://community.glideapps.com/t/verify-number-of-decimal-places/62884/6 "2023-06-18T20:03:48Z")

</div>

I have a forex trading business and this app is one that will calculate the future take profit and stop loss values. If we use a default ‘stop’ and ‘profit’ targets based on a cell with say 30 pips. A 2 digit currency will need that 30 to be .30 and a 4 digit currency will need it to be .0030 so that is why I need to know the digits before I input the entry price which is what the .30 or .0030 is added/subtracted from. Hope this helps explain. Example: Entry price input at 1.5955 for a buy would need the .0030 to be subtracted so the Stop price would be calculated to be 1.5925 or a sell would be 1.5955 added to the .0030 and stop price would be 1.5985.

---

<div class="post-metadata">

**Author:** ![nathanaelb](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nathanaelb/32/43079_2.png) [@nathanaelb](https://community.glideapps.com/u/nathanaelb)\
**Post date:** [June 18, 2023, 10:54pm UTC](https://community.glideapps.com/t/verify-number-of-decimal-places/62884/7 "2023-06-18T22:54:45Z")

</div>

Don’t you know ahead of time when you create a new currency in your app if it will have 2 or 4 digits?

If you don’t know, what would happen if the entry point for a 4-digit currency were 1.5900? Would you expect your app to identify that it was indeed a 4-digit currency?

---

<div class="post-metadata">

**Author:** ![pipharvester](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pipharvester/32/61697_2.png) [@pipharvester](https://community.glideapps.com/u/pipharvester)\
**Post date:** [June 18, 2023, 10:59pm UTC](https://community.glideapps.com/t/verify-number-of-decimal-places/62884/8 "2023-06-18T22:59:52Z")

</div>

This portion is to create an alert for a trade setup. So we are setting those up for any of 21 different currencies and we never know until we are inputting the alerts. I can manually do the math for each off the prices but would rather simply enter the “ENTRY PRICE” for a currency and have the math done in the other 2 automatically.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [June 19, 2023, 12:41am UTC](https://community.glideapps.com/t/verify-number-of-decimal-places/62884/9 "2023-06-19T00:41:05Z")

</div>

Try the following in a JavaScript column:

```auto
return (p1.toString().split('.')[1] || []).length;

```

![CleanShot 2023-06-19 at 08.37.16@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/c/ecaad5bd036a15432dd138d52291288975add771.png)

Note: in the example above I configured the Number column as a Text type. I only did that to preserve the formatting - it works the same if it’s configured as a Number type.

---

<div class="post-metadata">

**Author:** ![pipharvester](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/pipharvester/32/61697_2.png) [@pipharvester](https://community.glideapps.com/u/pipharvester)\
**Post date:** [June 19, 2023, 12:43am UTC](https://community.glideapps.com/t/verify-number-of-decimal-places/62884/10 "2023-06-19T00:43:45Z")

</div>

Thank you so much!!!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [June 20, 2023, 12:44am UTC](https://community.glideapps.com/t/verify-number-of-decimal-places/62884/11 "2023-06-20T00:44:34Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
