Operation with real variables and constants


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Operation with real variables and constants
# 1  
Old 10-24-2008
Operation with real variables and constants

Hello there,

I'd like to define a variable b equal to 0.5/a where a=0.001, so I wrote something like that:

a=0.001;
let 'b=0.5/$a';

but it doesn't work... maybe because the variable a has a real value???

Any help will be appreciated!!!Smilie
# 2  
Old 10-24-2008
Hammer & Screwdriver Try the following

Code:
> a=0.001
> b=0.5/$a
> echo $b
0.5/0.001
> c=`echo 0.5 / $a | bc`
> echo $c
500
>

This User Gave Thanks to joeyg For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Column operation : cosne and sine operation

I have a txt file with several columns and i want to peform an operation on two columns and output it to a new txt file . file.txt 900.00000 1 1 1 500.00000 500.00000 100000.000 4 4 1.45257346E-07 899.10834 ... (4 Replies)
Discussion started by: shashi792
4 Replies

2. UNIX for Dummies Questions & Answers

string operation

I am trying to ask for full name in a script, Then echo back to the user with the surname only, omitting the first name. Thanks (2 Replies)
Discussion started by: orjnet
2 Replies

3. Programming

char constants vs. hard-coding

This might be a silly question, but I thought I'd ask anyway. If I'm writing in C, isn't it more efficient to, for instance, use constant character variable set to 'A' instead of hard-coding a character 'A'? Since it's only a single character instead of a string, it might not matter much. (10 Replies)
Discussion started by: cleopard
10 Replies

4. Programming

How to convert byteArray variables to HexaString variables for Linux?

Hello everybody, I am having problem in converting byte array variables to Hexa String variables for Linux. I have done, converting byte array variables to Hexa String variables for Windows but same function doesn't work for linux. Is there any difference in OS ? The code for Windows is given... (2 Replies)
Discussion started by: ritesh_163
2 Replies

5. Shell Programming and Scripting

string operation

i am new user of unix.i have a question.My script is- export STR_ALFA=`head -2 "${FILE_PATH}"|tail -1|cut -d"," -f1` "${TEST_HOME}"/function/chk_alfa.ksh STR_ALFA now i want to check STR_ALFA: 1)whether is alphabetic 2)whether is numeric 3)whether is alphanumeric... (1 Reply)
Discussion started by: arghya_owen
1 Replies

6. Shell Programming and Scripting

perl: eval and constants

is it possible to use eval to create constants in perl? i cannot seem to get anything to work, and my searches are turning up little to nothing. an example of what i am trying to do is this: 2 arrays: array 1: 'FOOD','NUMBER','OS' array 2: 'pizza','two','unix' loop through the arrays and... (5 Replies)
Discussion started by: effigy
5 Replies

7. Programming

constants in C/C++

Hi all My question is related to following sample code which tries to change consant value by pointers.(I know it is wrong practice but i am surprised by mis-behaviour) The code: #include <stdio.h> int main() { const int x = 10; int *y; const int * const z = &x; y = (int *)&x;... (2 Replies)
Discussion started by: Shobhit
2 Replies
Login or Register to Ask a Question