Hi all.
I have a procedure that acts as a calculator.
For multiplication ,addition and subtraction
it works well...The guts of the procedure is:
for {set r $num} {$r < [llength $sumlist]} {incr r} {
set sum [expr $sum == 0 ? [lindex $sumlist $r] : [expr $sum * [lindex $sumlist $r]]]
r_calc $sumlist $op $sum [expr $r + 1]
}
#main()
set a(1) [r_calc {12 54 67 89 2} / 0 0]
set a(2) [r_calc {32 45 12} + 0 0]
set a(3) [r_calc {43 56 78} - 0 0]
b_parray a
#end
The output of this sample:
a(1) = 2
a(2) = 89
a(3) = -91
a(1) should be something like 1.86334e-05 according
to a calculator.
Anybody know what the issue is?
I have a procedure that acts as a calculator.
For multiplication ,addition and subtraction
it works well...The guts of the procedure is:
for {set r $num} {$r < [llength $sumlist]} {incr r} {
set sum [expr $sum == 0 ? [lindex $sumlist $r] : [expr $sum * [lindex $sumlist $r]]]
r_calc $sumlist $op $sum [expr $r + 1]
}
#main()
set a(1) [r_calc {12 54 67 89 2} / 0 0]
set a(2) [r_calc {32 45 12} + 0 0]
set a(3) [r_calc {43 56 78} - 0 0]
b_parray a
#end
The output of this sample:
a(1) = 2
a(2) = 89
a(3) = -91
a(1) should be something like 1.86334e-05 according
to a calculator.
Anybody know what the issue is?