Note that if you're willing to use a 1993 or later Korn shell instead of bash, it is happy to perform arithmetic substitutions in floating point:
Note that if the decimal point had been omitted in the calculation marked above in red, ksh would have used integer arithmetic instead of floating point.
Trying to figure out why this works:
printpwd.pl
#!/usr/bin/perl
use CGI::Carp qw( fatalsToBrowser );
print "Content-type: text/html\n\n";
$A = system("pwd");
$A = `pwd`;
print "$A\n";
^^actually that works/breaks if that makes any sense.. i get the working directory twice but when... (5 Replies)
Hi there,
I am totally new to Unix, I am trying to work out the percentage between two values in a ksh shell script and assign the result to a variable.
Value1=577
Values2=244
So the calculation would be as follows:
((Value1 - Value2) / Value1) * 100
How would I be able to achieve... (2 Replies)
hello,
please can you help me.
jj and kk are two numbers which are the result of an sql program.
I would like to calculate the ratio jj/kk*100.
I have done this:
ratio=$((jj/kk * 100)) or ratio=`expr $jj \/ expr $kk) but the result is 0
What can i do?
Thanks for help. (3 Replies)
Hi all,
I havea log of data.log
bear,10000,white
bear,5000,black
chicken,2000,white
chicken,4000,yellow
chicken,3000,black
lion,6000,yellow
lion,1000,white
How can we have shell script to get the percentage of each animals?
Thanks. (8 Replies)
Shell Scipt: temp.sh
su - <$username>
expect pass.exp
Expect script: pass.exp
#!/usr/bin/expect -f
# Login
#######################
expect "Password: " send "<$password>\r"
it comes up with Password: but doesnt take password passed throguh file. (2 Replies)
Hello,
I am trying to compute the percentage in a script as shown below:
PerCover=`echo "scale=2 ; 100 \* ($InputCover/$Total)" | bc`
However the PerCover value is blank/null. What do I need to do differently?
Thanks for your input!
~Guss (1 Reply)
Dear All,
I have script.
Dest=""
IFS='
'
for translation in $(echo $MY_MAP)
do
t1=$(echo $translation | cut -d"=" -f1)
t2=$(echo $translation | cut -d"=" -f2| cut -d"," -f1)
if
then
Dest=$UNX/$u_product_path/$u_study_path/$UNXTR/$t2
break;
... (4 Replies)
Hi there
I am middle of writing a script to allow me to see the % of the memory which is being used.
When I submit my script I don't get any errors but I just get a blank output.
Any pointers?
available=`free -m | grep available`
if
then
... (7 Replies)
having two columns, A and B.. i need to add another column C in a file and calculate the percentage based on the column A and B. (COLUMN B/ COLUMN A *100) . "|" is delimiter separating the A and B.. need C column with the percentage value. Thanks for your help
100|50 |50% ... (6 Replies)
Discussion started by: kartikirans
6 Replies
LEARN ABOUT HPUX
fenv
fenv(5) File Formats Manual fenv(5)NAME
fenv - floating-point environment macros and functions
SYNOPSIS DESCRIPTION
The header declares two types and several macros and functions to provide access to the floating-point environment. The floating-point
environment refers collectively to the floating-point status flags and control modes. A floating-point status flag is a system variable
whose value is set (but never cleared) when a floating-point exception is raised, which occurs as a side effect of exceptional floating-
point arithmetic to provide auxiliary information. A floating-point control mode is a system variable whose value may be set by the user
to affect the subsequent behavior of floating-point arithmetic; on HP 9000 and HP Integrity servers the control modes include the rounding
direction mode, the gradual/flush-to-zero underflow mode, and the trap enables.
For HP-UX 11i v3 September 2008 Update (and later) for Integrity servers, the floating-point environment also includes the rounding direc-
tion mode for decimal floating point, which is independent of the rounding direction mode for binary floating point. Both binary and deci-
mal floating point use the same status flags.
The following types are defined:
Represents the entire floating-point environment.
Represents the floating-point exception flags collectively.
The following macros represent the floating-point status flags. They are defined as integral constant expressions with values such that
bitwise ORs of all combinations of the macros result in distinct values.
The inexact exception.
The division-by-zero exception.
The underflow exception.
The overflow exception.
The invalid operation exception.
The bitwise OR of all exception macros.
The following macros represent the rounding direction modes for binary floating point. They are defined as integral constant expressions
with distinct nonnegative values.
The round-to-nearest rounding direction mode.
The round-toward-positive-infinity rounding direction mode.
The round-toward-negative-infinity rounding direction mode.
The round-toward-zero rounding direction mode.
The following macro is defined as a pointer to const-qualified
The default floating-point environment.
To the ISO/IEC C99 specified facilities, the HP implementation adds four HP-specific functions: and
For HP-UX 11i v3 September 2008 Update (and later) for Integrity servers, included in a compilation where has been defined, this file
defines the following macros representing the rounding direction modes for decimal floating point. They are for use with the and functions.
They are defined as integral constant expressions with distinct nonnegative values.
The round-to-nearest decimal rounding direction mode with ties
(half-way cases) to even.
The round-toward-positive-infinity decimal rounding direction mode.
The round-toward-negative-infinity decimal rounding direction mode.
The round-toward-zero decimal rounding direction mode.
The round-to-nearest decimal rounding direction mode with ties
(half-way cases) away from zero.
To use any of the types or macros for decimal floating point, define either with a compile option, or with
in the source file before inclusion of
FILES SEE ALSO fe_dec_getround(3M), fe_dec_setround(3M), feclearexcept(3M), fegetexceptflag(3M), feraiseexcept(3M), fesetexceptflag(3M), fetestexcept(3M),
fegetround(3M), fesetround(3M), fegetenv(3M), feholdexcept(3M), fesetenv(3M), feupdateenv(3M), fegetflushtozero(3M), fesetflushtozero(3M),
fegettrapenable(3M), fesettrapenable(3M), math(5).
STANDARDS CONFORMANCE
: ISO/IEC C99 (including Annex F, "IEC 60559 floating-point arithmetic"), ISO/IEC TR 24732
fenv(5)