08-02-2007
Multiplying Floats/Decimals
Use "bc" here:
$ Number=`echo 80 \* 10.69 |bc`; echo $Number
855.20
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
$ a=10 ; b=2
$ expr $a + $b
12
$ expr $a - $b
8
$ expr $a / $b
5
$ expr $a * $b
expr: syntax error
Any idean why I am getting this error only when multiplying two numbers. Whats the exact syntax?
Thanks a lot to all in advance
CSaha (5 Replies)
Discussion started by: csaha
5 Replies
2. Shell Programming and Scripting
Hi,
I am trying to find if there is a way to convert regular decimal values to Paced decimal values. I tried to find a c program but I could get a Packed converted to regular decimal not the other way round.
If not unix please let me know if any other progrimming language I can use to do... (2 Replies)
Discussion started by: mgirinath
2 Replies
3. Shell Programming and Scripting
(4 Replies)
Discussion started by: puddy
4 Replies
4. Shell Programming and Scripting
Hello. I have a problem with AWK and floats below 0 in a script.
It may be simplified to this line (please, take into account that my "locale" is Spanish, so the system will read "," as decimal separator):
echo -1,25 2,55745 0,33 ,278 | awk '{print $1+1, $2+1, $3+1, $4+1}'... getting:
-0,25... (4 Replies)
Discussion started by: JCastro
4 Replies
5. Shell Programming and Scripting
I am using gawk in a dos shell in windows xp and want to read a datafile and reformat it.
The datafile consists of columns of integers, floating point numbers and text strings. Each column is a fixed width and each column contains the same data type, eg all integers, all text.
I am looking for a... (0 Replies)
Discussion started by: lookingfor help
0 Replies
6. Shell Programming and Scripting
I want to make computations using floats. This cannot be done with csh. ksh seem to have a problem as well. What is good shell for computations without having to resort to bc or awk? How about python? (5 Replies)
Discussion started by: kristinu
5 Replies
7. Programming
Hi, this is my code.It's simple : there are 2 2D arrays and the multiplied to C.
#include<stdio.h>
#include<sys/shm.h>
#include<sys/stat.h>
#include<stdlib.h>
main()
{
int *A; //A
int *B; //B
int *C; //C
int i,j,x,k,d;
int id;
... (17 Replies)
Discussion started by: giampoul
17 Replies
8. Shell Programming and Scripting
I am trying to take all the elements of an array and multiply them by 2, and then copy them to a new array. Here is what I have
i=0
for true in DMGLIST
do
let DMGSIZES2="${DMGSIZES}"*2
let i++
done
unset i
echo ${DMGSIZES2}
It does the calculation correctly for the first element,... (7 Replies)
Discussion started by: nextyoyoma
7 Replies
9. Programming
HI,
i am trying to multiply 2 2D arrays (a,b) using fork.
The answer will be at c.
Each child have to calculate 1 row of c.
The code is right, as i think of it, with no errors but i dont get the correct c array...
I think there is maybe a mistake in i dimension ...
Anyway, here is the code:
... (16 Replies)
Discussion started by: giampoul
16 Replies
10. Programming
I have this script which can calculate the total of numbers given in a string
total = 0
for c in '0123456789':
total += int(c)
print total
How should I modify this script to find the total of if the numbers given in the string form have decimal places? That is, how do I need to modify... (2 Replies)
Discussion started by: faizlo
2 Replies
LEARN ABOUT HPUX
hppaclongdi
hppac(3X) hppac(3X)
NAME
hppac: HPPACADDD(), HPPACCMPD(), HPPACCVAD(), HPPACCVBD(), HPPACCVDA(), HPPACCVDB(), HPPACDIVD(), HPPACLONGDIVD(), HPPACMPYD(), HPPAC-
NSLD(), HPPACSLD(), HPPACSRD(), HPPACSUBD() - HP 3000-mode packed-decimal library
SYNOPSIS
DESCRIPTION
This set of calls invokes the library functions for emulating 3000-mode (MPE V/E) packed-decimal operations. These functions are in
library which is searched when the option is used with or ld(1).
Performs packed-decimal addition.
Compares two packed-decimal numbers.
Converts an ASCII representation to packed-decimal.
Converts a binary representation to packed-decimal.
Converts a packed-decimal number to ASCII.
Converts a packed-decimal number to binary.
Performs packed-decimal division.
Performs packed-decimal division (alternate routine).
Performs packed-decimal multiplication.
Performs a packed-decimal normalizing left shift.
Performs a packed-decimal left shift.
Performs a packed-decimal right shift.
Performs packed-decimal subtraction.
For all operations, the value returned in the variable to which the compcode argument points is one of the following values of type
Result > 0 or operand1 > operand2
Result < 0 or operand1 < operand2
Result == 0 or operand1 == operand2
For all operations, the value returned in the variable to which the pacstatus argument points is one of the following values of type Their
meanings are intended to be obvious:
AUTHOR
The HPPAC library was developed by HP.
SEE ALSO
PA-RISC Systems Only hppac(3X)