Sponsored Content
Full Discussion: Maths with variables
Top Forums Shell Programming and Scripting Maths with variables Post 302388082 by DFr0st on Tuesday 19th of January 2010 10:38:43 AM
Old 01-19-2010
Maths with variables

Hello,
I'm trying to write a while loop for a decimal value in tcsh which I know can't be done. Instead I want my increments to be one order of magnitude too large and then divide it by 10 when I use the variable. However, I don't know how to divide my variable and set it as another.

Code:
set RI_min = 10
set RI_max = 30
set RI_inc = 1

# Run Flex2d for each RI
set RI = $RI_min
echo "Calculating flexure for:"
while ($RI <= $RI_max)

@ RI = $RI + $RI_inc

I then want to set PI to equal RI/10 to use PI in another program so my PI values will range from 1.0 to 3.0.
Thanks

Last edited by Scott; 01-19-2010 at 11:48 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with Maths

Heres a script i wrote as a bit of practise. What it does is insert a line in the middle of a file. The line being $1 and the file being $2 #!/bin/bash rm tempfile touch tempfile count=1 linenum= `wc -l < $2` if then echo $1 >> $2 else even=`expr "$linenum" % 2` if then... (3 Replies)
Discussion started by: Quesa
3 Replies

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

3. Shell Programming and Scripting

Perl - maths equation - need help

if input to the perl program is ' ( p * ((a+b) * (c+d))) + q ' it shuld give the output as ' pac + pad + pbc + pbd + q ' .can anyone suggest a way to do this ? (7 Replies)
Discussion started by: Anuj8584
7 Replies

4. Shell Programming and Scripting

Using IF statements with maths where the input is not an integer

Hi All I've made a few scripts which using GDAL extract the value of a pixel within a given raster. The purpose is to work out the combine value of every pixel. I thought there may have been an easier way to do this but alas! The code below extracts the pixel value at position X Y. The... (3 Replies)
Discussion started by: StudentFitz
3 Replies

5. Shell Programming and Scripting

Simple maths calculator loop.

Hi, I am trying to make a maths calculator that: 1. Prompts the user for a number. 2. Prompts the user for an operation (add, subtract, divide or multiply) 3. Prompts the user for a number. 4. Prompts the user for another operation (same as above) OR the option to get the result for the... (4 Replies)
Discussion started by: johnthebaptist
4 Replies

6. Shell Programming and Scripting

Maths in shell scripts

Hi, Need help on this. I need to increment a variable by 1 but retain as 2 characters. I am using expr to do additions: NEWSERIAL=`expr $SERIAL + 1` $SERIAL can range from 01-99. After adding "1", I need the result to be 2 characters, eg: 02+1 = 03. By default expr will truncate the... (4 Replies)
Discussion started by: vchee
4 Replies

7. Shell Programming and Scripting

Running a script with multiple variables like 25 variables.

Hi All, i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way?? #!/bin/ksh ##script is sample.ksh age=$1 gender=$2 class=$3 . . .... (3 Replies)
Discussion started by: Lakshman_Gupta
3 Replies

8. Shell Programming and Scripting

BASH arrays and variables of variables in C++

Sometimes it is handy to protect long scripts in C++. The following syntax works fine for simple commands: #define SHELLSCRIPT1 "\ #/bin/bash \n\ echo \"hello\" \n\ " int main () { cout <<system(SHELLSCRIPT1); return 0; } Unfortunately for there are problems for: 1d arrays:... (10 Replies)
Discussion started by: frad
10 Replies

9. Shell Programming and Scripting

Passing awk variables to bash variables

Trying to do so echo "111:222:333" |awk -F: '{system("export TESTO=" $2)}'But it doesn't work (2 Replies)
Discussion started by: urello
2 Replies

10. Shell Programming and Scripting

Calculate the constant e to 14+ decimal places using integer maths.

Hi guys... I am loving this integer maths thing. 64 bit systems are certainly easier than 32 bit, but hey, I don't intend to leave out my fav' platform. Using one of the 'Brothers' methods, URL inside the code. #!/bin/sh # # #!/usr/local/bin/dash # e_constant.sh # Brother's formula . #... (2 Replies)
Discussion started by: wisecracker
2 Replies
powd64(3M)																powd64(3M)

NAME
powd64(), powd128(), powd32() - decimal power functions SYNOPSIS
DESCRIPTION
The function returns is a version of it takes arguments and returns a result. is a version of it takes arguments and returns a result. These math functions are supported for HP-UX 11i Version 3 September 2008 Update and forward. USAGE
To use any of these functions, compile with the option. Make sure your program defines and then includes Link in the math library by specifying or on the linking command line. For more information, see the at the following site: RETURN VALUE
and raises the divide-by-zero floating-point exception for y an odd integer < 0. returns +infinity and raises the divide-by-zero floating-point exception for y<0 and not an odd integer. for y an odd integer > 0. returns +0 for y>0 and not an odd integer. returns 1. returns 1 for any x, even NaN. returns 1 for any x, even NaN. returns NaN and raises the invalid floating-point exception for finite x<0 and finite non-integer y. returns +infinity for |x|<1. returns +0 for |x|>1. returns +0 for |x|<1. returns +infinity for |x|>1. returns -0 for y an odd integer < 0. returns +0 for y<0 and not an odd integer. returns -infinity for y an odd integer > 0. returns +infinity for y>0 and not an odd integer. returns +0 for y<0. returns +inf for y>0. Otherwise, if either argument is NaN, then returns NaN. returns the properly signed infinity (or, in some non-default rounding direction modes, the properly signed maximum-magnitude finite num- ber) in lieu of a value whose magnitude is too large, and raises the overflow and inexact exceptions. raises the underflow exception whenever a result is tiny (essentially subnormal or zero) and inexact. raises the inexact exception whenever a rounded result does not equal the mathematical result. ERRORS
For finite x<0 and finite non-integer y, sets to sets to if y is an odd integer < 0. sets to if y<0 and not an odd integer. If the correct value would overflow, sets to SEE ALSO
cbrtd64(3M), expd64(3M), logd64(3M), scalblnd64(3M), scalbnd64(3M), sqrtd64(3M), math(5). STANDARDS CONFORMANCE
These functions conform to ISO/IEC TR 24732, "Extension for the programming language C to support decimal floating-point arithmetic". HP Integrity Server Only powd64(3M)
All times are GMT -4. The time now is 07:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy