Feb 20, 2003 #1 MED Programmer Aug 13, 2001 4 GB Help! I'm having problems adding numbers with decimal points. I need an answer with decimal points but it keeps rounding down. This is the line that I'm using - TOTAL=$((TOTAL+$AMT)) Can anyone point me in the right direction? Thanks!
Help! I'm having problems adding numbers with decimal points. I need an answer with decimal points but it keeps rounding down. This is the line that I'm using - TOTAL=$((TOTAL+$AMT)) Can anyone point me in the right direction? Thanks!
Feb 20, 2003 #2 vgersh99 Programmer Jul 27, 2000 2,146 US shell arithmetic is integer ONLY: TOTAL=$(echo "${TOTAL}+${AMT}" | bc) vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+ Upvote 0 Downvote
shell arithmetic is integer ONLY: TOTAL=$(echo "${TOTAL}+${AMT}" | bc) vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+
Feb 20, 2003 #3 SmartDen Programmer Feb 18, 2003 8 DE which language do you use? shell, awk?.. Upvote 0 Downvote
Feb 20, 2003 #5 olded Programmer Oct 27, 1998 1,065 US MED: Vlad's right about ksh arithmetic being integer only. That's ksh88. However, the ksh93 version does support decimal arithmetic: This works on my solaris 7 box: #!/usr/dt/bin/dtksh let sum=$((5.2+6.3)) printf "%f\n" $sum # end script The dtksh shell is 93 compliant. Regards, Ed Upvote 0 Downvote
MED: Vlad's right about ksh arithmetic being integer only. That's ksh88. However, the ksh93 version does support decimal arithmetic: This works on my solaris 7 box: #!/usr/dt/bin/dtksh let sum=$((5.2+6.3)) printf "%f\n" $sum # end script The dtksh shell is 93 compliant. Regards, Ed