This seemingly simple question is difficult to solve completely in bc itself because it simply does not calculate in that fashion. The rounding at least can be done by adding 0.005 and truncating down to two decimal places. I don't think adding 0.01 is correct.
These 2 Users Gave Thanks to Corona688 For This Post:
i have a script in which awk prints "($2-1700)/10000"
and the answer is -0.07,but i want the answer in 4 decimal places.
that is -0.0700.
How can i sue awk to get my results in four decimal places (4 Replies)
i need to multiplay a number with 1.00.. so that the output should contain two decimal places at end..
for example...
236 * 1.00 = 236.00
245.8 * 1.00 = 245.80
but when i perform multiplication it shows output as.
236
245.8
can anyone help me to get the actual output of... (11 Replies)
Hi
I have a big file with lines like below
<tr align="center" bgcolor="SEASHELL"><td>94% </td><td>4.62178 </td><td>73.4375 </td></tr>
<tr align="center" bgcolor="SEASHELL"></td><td>97% </td><td>3.2962 </td><td>125 </td></tr>
I want to format the file such that i get like below. i.e... (3 Replies)
I am trying to perform arithmetric, for example, to increment the value of variable $a (say 3) by 0.05 but when I tried the following expression
let a=a+0.05
or a=$((a+0.05))
both returned
3.0499999999999998
I want to keep 2 decimal places so it returns 3.05 instead. (6 Replies)
I have input file like below,
201424|9999|OSS|622010|RGT|00378228764
201424|8888|OM|587079|RGT|00284329675
201424|7777|OM|587076|RGT|00128671024
201424|6666|OM|581528|RGT|00113552084
Output should be like below, should add decimal (.) from last 4 digits.
... (2 Replies)
I used the below script to Sum up a field in a file based on some unique values. But the problem is when it is summing up the units, it is truncating to 2 decimals and not 6 decimals as in the input file (Input file has the units with up to 6 Decimals – Sample data below, when the units in the 2... (4 Replies)
Discussion started by: brlsubbu
4 Replies
LEARN ABOUT HPUX
fe_dec_getround
fe_dec_getround(3M)fe_dec_getround(3M)NAME
fe_dec_getround() - get decimal floating-point rounding direction mode
SYNOPSIS DESCRIPTION
The function gets the current decimal rounding direction.
The default decimal rounding direction mode is round to nearest with half-way cases away from zero
These math functions are supported for HP-UX 11i Version 3 September 2008 Update and forward.
USAGE
To use this function, compile with the option.
Make sure your program defines and then includes
Specify on the compiler command line or place the call to this function under the effect of an affirmative pragma:
If the pragma is placed outside of any top-level declarations in a file, the pragma will apply until another pragma is encountered or until
the end of the file is reached.
If the pragma is placed at the beginning of a block (compound statement), the pragma will apply until another pragma is encountered or
until the end of the block is reached.
Link in the math library by specifying or on the linking command line.
For more information, see the at the following site:
RETURN VALUE
The function returns the value of the decimal rounding direction macro representing the current decimal rounding direction. The return
value will match one of the following macros, which are defined in
Round to nearest. If the two nearest representable are equally near,
the one with its least significant bit zero is delivered.
Round to nearest. If the two nearest representable are equally near,
the one furthest from zero is delivered.
Round upwards (towards +infinity).
Round downwards (towards -infinity).
Round toward zero.
ERRORS
No errors are defined.
EXAMPLES
Save, set, and restore the decimal rounding direction.
SEE ALSO fe_dec_setround(3M), fenv(5).
STANDARDS CONFORMANCE
This function conforms to ISO/IEC TR 24732, "Extension for the programming language C to support decimal floating-point arithmetic".
fe_dec_getround(3M)