Page 1 of 1

How to calculate digital roots in DSP?

PostPosted: Mon Apr 02, 2018 7:38 pm
by guyman
I'd like to learn about modular iterations and operations in dsp code. wiki on subject > https://en.wikipedia.org/wiki/Digital_root

example..

dr(45) = 9
4+5 = 9

or

dr(1618) = 16
1 + 6 + 1 + 8 = 16

or to further reduce to one digit

1 + 6 = 7

how do we perform these modular operations in DSP code?

streamin x;
streamout out;
float y;
y = dr(x);
out = y;

Re: How to calculate digital roots in DSP?

PostPosted: Tue Apr 03, 2018 10:14 am
by martinvicanek
Code: Select all
streamin n;
streamout dr;
dr = 1 + (n - 1)%9;