How to calculate digital roots in DSP?

DSP related issues, mathematics, processing and techniques
Post Reply
User avatar
guyman
Posts: 207
Joined: Fri Mar 02, 2018 8:27 pm

How to calculate digital roots in DSP?

Post 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;
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: How to calculate digital roots in DSP?

Post by martinvicanek »

Code: Select all

streamin n;
streamout dr;
dr = 1 + (n - 1)%9;
Post Reply