1833323 Members
3190 Online
110051 Solutions
New Discussion

array elements

 
ehab_2
Occasional Contributor

array elements

Why rr[h]*oo[h] does not work
I am trying to multiply 2 elemtnts from different arrays the result is 0 WHY ?
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor

Re: array elements

I assume this is a shell question. The shell doesn't know what '*' by itself means. We need to give it a little help to know that this is an arithmatic problem.

X=$((${a} * ${b}))

and if this is an array that becomes
X=$((${rr[${h}]} * ${oo[${h}]}))

NOTE: This is integer arithmatic only; the shell does not understand floating point.
If it ain't broke, I can fix that.