Development
...
Basics
Signa and Planck
1 min
the basic token (coin) on signum is called signa (ticker signa) one signa can be divided into up to eight decimals places the smallest possible unit is called planck, i e 1 planck = 0 00000001 signa (1^10 8) 1 signa = 100,000,000 planck the docid\ yynxycqblmbwflxzom4c6 always returns the values in planck, and their fields are always denominated with the suffix nqt see an example https //europe signum network/api doc/index html#get /api requesttype getaccount to facilitate the calculations signumjs provides the value object calls amount https //signum network github io/signumjs/classes/util amount html and allows to convert and calculate between signa and planck const {amount} = require("@signumjs/util"); console log('one signa is', amount fromsigna(1 0) getplanck(), 'planck') console log('one planck is', amount fromplanck(1) getsigna(), 'signa') console log('10 signa + 245,000 planck =', amount fromsigna(10) add(amount fromplanck(245000)) getsigna(), 'signa') console log('10 signa + 245,000 planck =', amount fromsigna(10) add(amount fromplanck(245000)) getplanck(), 'planck') console log('50,000 planck 16 =', amount fromplanck(50 000) multiply(16) getsigna(), 'signa') console log('2 signa < 40,000 planck is ', amount fromsigna(2) less(amount fromplanck(40 000))) // mind that multiply, add, subtract and divide mutates the value object const mutatedvalue = amount fromsigna(1) mutatedvalue add(amount fromsigna(2 65)) console log('value is', mutatedvalue getsigna()) javascript is pretty bad at numeric precision, i e the maximum integer number is 2^53 1 and has infamous precision on floating point numbers signumjs uses https //mikemcl github io/bignumber js/ to guarantee precise calculations this is the reason you should always use amount (and chainvalue) when calculating numbers