can array store float point numbers


 
Thread Tools Search this Thread
Operating Systems Solaris can array store float point numbers
# 1  
Old 03-05-2008
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
# 2  
Old 03-05-2008
Code:
#!/bin/ksh

set -A a

for i in 1 2 3 4 5 6 7 8
do
  a[$i]=$(bc <<-%
  sc=6
  1 / $i
  %)
  printf "%d %f\n" $i ${a[$i]}
done

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help about using variables of float numbers in sed

Hi, I need to run a Fortran program which reads a input file with a fixed name many times, each time I need to change a number (real) in that input file, this is how I currently do it and I know it is not elegent at all: cp inputfile.dat backup.dat sed -i 's/28.0/0.01/g' inputfile.dat ./myCode... (3 Replies)
Discussion started by: dypang
3 Replies

2. Shell Programming and Scripting

Float array sum

Hi everyone, I'm having some trouble with float array. When i try to get the array sum with float numbers i get this error line 39: soma + 2.34 | bc: syntax error: invalid arithmetic operator (error token is ".34 | bc") 26 Somar() { 27 echo "Quantos numeros deseja somar?" 28 read... (4 Replies)
Discussion started by: berveglieri
4 Replies

3. Shell Programming and Scripting

Floating Point Numbers in c shell!

I have started using bash but this script which I am working on it, is in c chell. So here is my simple problem: set x = 0.4124\0.234 echo $x 0.4124.0.234 Same operation in Bash gives me correct result in my terminal. So there is something with my c shell that is causing this behaviour.... (8 Replies)
Discussion started by: dixits
8 Replies

4. Shell Programming and Scripting

Store all the passed arguments in an array and display the array

Hi I want to write a script which store all the parameters passed to the script into an array. Once it is stored I want scan through the array and and delete those files for last month present inside the directory. The files in directory is appneded with YYYY_MM_DD. I want to know how can I... (3 Replies)
Discussion started by: dgmm
3 Replies

5. Shell Programming and Scripting

Random float numbers in BASH

Hi people :) I'm learning shell scripting using bash and I want to generate 4 floating point number with 5 decimal places and write them to a file and a variable. I've done all this except the $RAMDOM enviroment variable does not generate a float number but a integrer. I hope you could... (3 Replies)
Discussion started by: pharaoh
3 Replies

6. Shell Programming and Scripting

floating point numbers in if

# if > then > echo "1" > else > echo "2" > fi -bash: How can i compare floating point numbers inside statement? (15 Replies)
Discussion started by: proactiveaditya
15 Replies

7. Programming

comparison between float numbers

Hi, i have a simple control like this: if(sum>1.0)... If i try to print sum i get 1.000000 but the check returns true. I think it depends on float precision. How can i modify the check? thanks (1 Reply)
Discussion started by: littleboyblu
1 Replies

8. 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

9. Shell Programming and Scripting

adding float numbers

how to add 2 float values to each other? i tried this and it doesnt work: #!bin/bash numone=1.234 numtwo=0.124 total=`expr $numone + $numtwo` echo $total thanks (5 Replies)
Discussion started by: strike
5 Replies
Login or Register to Ask a Question