Sponsored Content
Full Discussion: Float array sum
Top Forums Shell Programming and Scripting Float array sum Post 302881645 by Don Cragun on Monday 30th of December 2013 05:18:33 PM
Old 12-30-2013
Note that if you use a 1993 or later ksh, you can just use something like:
Code:
soma=0
for i in ${vetorSoma[@]}; do
        soma=$((soma + $i))
done
printf "O resultado foi %.2f\n" "$soma"

Obviously, adjust the number in red above to set the number of digits you want displayed after the decimal point in your results.
 

9 More Discussions You Might Find Interesting

1. Programming

math.h: float ceilf(float x)

Good morning, I'm testing the use of ceilf: /*Filename: str.c*/ #include <stdio.h> #include <math.h> int main (void) { float ceilf(float x); int dev=3, result=0; float tmp = 3.444f; printf("Result: %f\n",ceilf(tmp)); return 0; } (1 Reply)
Discussion started by: jonas.gabriel
1 Replies

2. Solaris

i cannot assign float point numbers to an array in solaris

total=0 declare -a sum limit=`iostat -En | grep -i size | awk '{print $2}' | sed -e 's/GB//g' | wc -l` echo "Limit is equal to $limit" ara="`iostat -En | grep -i size | awk '{print $2}' | sed -e 's/GB//g'`" for (( i=1; i<=$limit; i++ )) do sum=`echo $ara | cut -d " " -f $i` echo ${sum}... (11 Replies)
Discussion started by: naree
11 Replies

3. Solaris

can array store float point numbers

Hi all, I have doubt can array in a shell script can store floating point numbers. i have tired. but i unable to work it out. Please help me regarding this Thank U Naree (1 Reply)
Discussion started by: naree
1 Replies

4. Shell Programming and Scripting

perl sum 2nd field in an array

Hi Everyone, ($total+=$_) for @record; assume @record=(1,2,3), so the result is 6. if @record=("1 3","2 3","3 3"), would like to sum up the 2nd field of this array, the result is 9. i tried " ($total+=$) for @record ", cannot, please advice. Thanks ---------- Post updated at 03:45... (1 Reply)
Discussion started by: jimmy_y
1 Replies

5. Shell Programming and Scripting

need [HELP] sum array multiple files

Hi.. I'm very newbie here.. I wonder if somebody can help me.. I have multiple directories with same out file name for each directories.. ./dirA/out.dat ./dirB/out.dat ./dirC/out.dat ..and so on.. for ./dirA/out.dat here is the structure content : for ./dirB/out.dat the same... (6 Replies)
Discussion started by: agiantz
6 Replies

6. UNIX for Dummies Questions & Answers

need [HELP] sum array multiple files

Hi.. I'm very newbie here.. I wonder if somebody can help me.. I have multiple directories with same out file name for each directories.. ./dirA/out.dat ./dirB/out.dat ./dirC/out.dat ..and so on.. for ./dirA/out.dat here is the structure content : for ./dirB/out.dat the same... (4 Replies)
Discussion started by: agiantz
4 Replies

7. Shell Programming and Scripting

Using awk to find sum of an array

Hi I am really new to awk and using shell script but I am wondering if its possible to find the sum of an array? I looked online but most of the things there are confusing, and when I tried it on my own it kept giving me the value of the last entry into the array for the sum. I have an array... (2 Replies)
Discussion started by: razrnaga
2 Replies

8. Shell Programming and Scripting

Help with Associative array to sum & Average

Hi All, I got stuck up with shell script where i use awk. The scenario which i am working on is as below. I have a file text.txt with contents COL1 COL2 COL3 COL4 1 A 500 200 1 B 500 300 2 A 290 150 2 B 290 140 3 C 100 100 I could able to sum col 3 and col4 based on col1 using... (1 Reply)
Discussion started by: imsularif
1 Replies

9. Shell Programming and Scripting

Help reading the array and sum of the array elements

Hi All, need help with reading the array and sum of the array elements. given an array of integers of size N . You need to print the sum of the elements in the array, keeping in mind that some of those integers may be quite large. Input Format The first line of the input consists of an... (1 Reply)
Discussion started by: nishantrefound
1 Replies
wxGraphicsPath(3erl)					     Erlang Module Definition					      wxGraphicsPath(3erl)

NAME
wxGraphicsPath - See external documentation: wxGraphicsPath. DESCRIPTION
See external documentation: wxGraphicsPath . This class is derived (and can use functions) from: wxGraphicsObject DATA TYPES
wxGraphicsPath() : An object reference, The representation is internal and can be changed without notice. It can't be used for comparsion stored on disc or distributed for use on other nodes. EXPORTS
moveToPoint(This::wxGraphicsPath(), P::{X::float(), Y::float()}) -> ok See external documentation . moveToPoint(This::wxGraphicsPath(), X::float(), Y::float()) -> ok See external documentation . addArc(This::wxGraphicsPath(), C::{X::float(), Y::float()}, R::float(), StartAngle::float(), EndAngle::float(), Clockwise::bool()) -> ok See external documentation . addArc(This::wxGraphicsPath(), X::float(), Y::float(), R::float(), StartAngle::float(), EndAngle::float(), Clockwise::bool()) -> ok See external documentation . addArcToPoint(This::wxGraphicsPath(), X1::float(), Y1::float(), X2::float(), Y2::float(), R::float()) -> ok See external documentation . addCircle(This::wxGraphicsPath(), X::float(), Y::float(), R::float()) -> ok See external documentation . addCurveToPoint(This::wxGraphicsPath(), C1::{X::float(), Y::float()}, C2::{X::float(), Y::float()}, E::{X::float(), Y::float()}) -> ok See external documentation . addCurveToPoint(This::wxGraphicsPath(), Cx1::float(), Cy1::float(), Cx2::float(), Cy2::float(), X::float(), Y::float()) -> ok See external documentation . addEllipse(This::wxGraphicsPath(), X::float(), Y::float(), W::float(), H::float()) -> ok See external documentation . addLineToPoint(This::wxGraphicsPath(), P::{X::float(), Y::float()}) -> ok See external documentation . addLineToPoint(This::wxGraphicsPath(), X::float(), Y::float()) -> ok See external documentation . addPath(This::wxGraphicsPath(), Path::wxGraphicsPath()) -> ok See external documentation . addQuadCurveToPoint(This::wxGraphicsPath(), Cx::float(), Cy::float(), X::float(), Y::float()) -> ok See external documentation . addRectangle(This::wxGraphicsPath(), X::float(), Y::float(), W::float(), H::float()) -> ok See external documentation . addRoundedRectangle(This::wxGraphicsPath(), X::float(), Y::float(), W::float(), H::float(), Radius::float()) -> ok See external documentation . closeSubpath(This::wxGraphicsPath()) -> ok See external documentation . contains(This::wxGraphicsPath(), C::{X::float(), Y::float()}) -> bool() Equivalent to contains(This, C, []) . contains(This::wxGraphicsPath(), X::float() | term(), X::float() | term()) -> bool() See external documentation . Alternatives: contains(This::wxGraphicsPath(), X::float(), Y::float()) -> contains(This,X,Y, []) contains(This::wxGraphicsPath(), C::{X::float(),Y::float()}, [Option]) -> bool() Option = {fillStyle, integer()} contains(This::wxGraphicsPath(), X::float(), Y::float(), Options::[Option]) -> bool() Types Option = {fillStyle, integer()} See external documentation . getBox(This::wxGraphicsPath()) -> {X::float(), Y::float(), W::float(), H::float()} See external documentation . getCurrentPoint(This::wxGraphicsPath()) -> {X::float(), Y::float()} See external documentation . transform(This::wxGraphicsPath(), Matrix::wxGraphicsMatrix() (see module wxGraphicsMatrix)) -> ok See external documentation . AUTHORS
<> wxErlang 0.98.9 wxGraphicsPath(3erl)
All times are GMT -4. The time now is 08:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy