Skip to main content
Solved

Setting precision for 12 places after the decimal for Crypto API

  • October 14, 2021
  • 2 replies
  • 52 views

Forum|alt.badge.img+7

Hi all,
I’m getting crypto prices from the Coinmarketcap API and the prices have 12 decimal places E.g. $0.000000007269

However, when I fetch the prices into Airtable, the field [Prices] has precision set to 1.0000000 - 7 places and missing the remaining 5 places.

Is there a way to resolve this?

Thanks in advance,
Paul

Best answer by Justin_Barrett

One option is to save it into a text field. If you need to use it in any calculations, wrap the field reference in the VALUE() function to turn it back into a number. To display the result, concatenate it with an empty string to re-stringify it. It’s a few extra steps, but the precision should be maintained (knock on wood; I’ve never done super precise math with Airtable formulas, so I recommend running tests to ensure that this process will work for your use case).

2 replies

Justin_Barrett
Forum|alt.badge.img+21
  • Inspiring
  • Answer
  • October 17, 2021

One option is to save it into a text field. If you need to use it in any calculations, wrap the field reference in the VALUE() function to turn it back into a number. To display the result, concatenate it with an empty string to re-stringify it. It’s a few extra steps, but the precision should be maintained (knock on wood; I’ve never done super precise math with Airtable formulas, so I recommend running tests to ensure that this process will work for your use case).


kuovonne
Forum|alt.badge.img+29
  • Brainy
  • October 17, 2021

A number/currency field is capable of storing a number with 12 decimal places if you set the value via scripting API. However, the user interface will not show these additional decimal places. You can see that the extra decimal places are stored in the editable field by using a formula field to convert the value to a string (e.g. {price} & "").