Sponsored Content
Full Discussion: Round floor behavior
Top Forums Programming Round floor behavior Post 303016028 by Corona688 on Wednesday 18th of April 2018 11:12:34 AM
Old 04-18-2018
Undeclared functions are assumed to return integers, which would cause weird results here - it would take the double result as a 32-bit integer, and so take the lower 32-bits of the double, pass that into printf, and print that.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to round a value

Hello, In a unix shell script,i want to round a variabele to a nearest number Ex: set count=104.4 How can i round that to 105.? Thanks, Sateesh (2 Replies)
Discussion started by: kotasateesh
2 Replies

2. Shell Programming and Scripting

round in KSH

Is there an easy way to round a number up in Korn shell? ie. 10.4 --> 11 Thanks. (6 Replies)
Discussion started by: here2learn
6 Replies

3. Shell Programming and Scripting

round a number

In a shell script - How do I round a decimal number (contained in a variable) to the nearest whole number? (2 Replies)
Discussion started by: achieve
2 Replies

4. Shell Programming and Scripting

FLOOR Func

Hello Experts, Is there any inbuild FLOOR function to do FLOOR func in mathmetics in awk script like in FlOOR Func in C. Ex:- floor(2.9) = 2 floor(2.1) = 2 floor(2.0) = 2 floor(-2.0) = 2 floor(-2.1) = -3 floor(-2.9) =... (1 Reply)
Discussion started by: user_prady
1 Replies

5. Shell Programming and Scripting

Round the column value :

Hi .... Iam having the file ....in which 3rd column is numerical having 8 decimal part... i want that to cut to 2 decimal part ... Source File : E100|0|19940.10104030|0|1ABC E103|1|19942.10195849|3|0ABC E100|0|19943.10284858|0|1ABC I want to be ...... Reulst: ... (4 Replies)
Discussion started by: satyam_sat
4 Replies

6. Shell Programming and Scripting

Round with awk

Hi, I have a problem. Basically I dont know how to use awk. I have a script (below) which works fine. What I want to do is somehow "pipe" in the input say 4.5 and have it give the anwer, I dont want ot have to type it in, since it will be running in a script. Any ideas how to do this???? ... (1 Reply)
Discussion started by: AnnaLynn
1 Replies

7. Shell Programming and Scripting

Round off the a Decimal value.

HI, I have a script which is used to calculate the Memory & CPU utilization a server. memx=`ssh -l siebel1 ${f} /usr/sbin/prtconf|grep -i 'Memory size'|tr -s " "|/usr/xpg4/bin/awk -F" " '{print $3 * 1024}'` v5=`ssh -l siebel1 ${f} vmstat 1 2 | tail -1 | tr -s " " | /usr/xpg4/bin/awk -v... (3 Replies)
Discussion started by: dear_abhi2007
3 Replies

8. Shell Programming and Scripting

How to round up on fives in unix?

i'm a newbie here, i need help with a shell script. for a given number, if it is greater than ten round to the nearest 10 same for 100, if it is greater than 100 round to the nearest 100, and same for 1000. i'm confused how to start this... its supposed to look like this input ... (11 Replies)
Discussion started by: CRAZYLITTLELOU
11 Replies

9. Shell Programming and Scripting

CEILING and FLOOR functions

Hi all, Does anyone know how to simulate a ceiling or floor function in UNIX? OS is Solaris. I tried the suggestion from an old forum but it is giving me error as below: server01/tmp$: echo "7.2" | awk '{printf("%d\n",$0+=$0<0?0:0.999)}' awk: syntax error near line 1 awk: illegal... (3 Replies)
Discussion started by: newbie_01
3 Replies

10. Shell Programming and Scripting

Round up the decimals

Hi All, I would like to do the following in the shell script 561.76 to 562 I tried using this echo 'scale=0; 749 * 75 /100 ' | bc but just returned only 561 Please help me . I appreciate your help Thanks rajeevm (13 Replies)
Discussion started by: rajeevm
13 Replies
exp(3m) 																   exp(3m)

Name
       exp, expm1, log, log10, log1p, pow - exponential, logarithm, power

Syntax
       #include <math.h>

       double exp(x)
       double x;

       float fexp(x)
       float x;

       double expm1(x)
       double x;

       float fexpm1(x)
       float x;

       double log(x)
       double x;

       float flog(x)
       float x;

       double log10(x)
       double x;

       float flog10(x)
       float x;

       double log1p(x)
       double x;

       float flog1p(x)
       float x;

       double pow(x,y)
       double x,y;

Description
       The and functions return the exponential function of x for double and float data types, respectively.

       The and functions return exp(x-1 accurately, including tiny x for double and float data types, respectively.

       The and functions return the natural logarithm of x for double and float data types, respectively.

       The and functions return the logarithm of x to base 10 for double and float data types, respectively.

       The and functions return log(1+x) accurately, including tiny x for double and float data types, respectively.

       The function returns x**y.

   Error (due to roundoff)
       The and functions are accurate to within an ulp, and is accurate to within approximately 2 ulps; an ulp is one Unit in the Last Place.

       The  function  is accurate to within 2 ulps when its magnitude is moderate, but becomes less accurate as the result approaches the overflow
       or underflow thresholds.  Theoretically, as these thresholds are approached, almost as many bits could be lost from the result as are indi-
       cated  in  the exponent field of the floating-point format for the resultant number.  In other words, up to 11 bits for an IEEE 754 double-
       precision floating-point number.  However, testing has never verified loss of precision as drastic as 11 bits.  The worst cases have  shown
       accuracy  of  results  to within 300 ulps for IEEE 754 double-precision floating-point numbers.	In general, a (integer, integer) result is
       exact until it is larger than 2**53 (for IEEE 754 double-precision floating-point).

Return Values
       All of the double precision functions return NaN if x or y is NaN.

       The function returns HUGE_VAL when the correct value would overflow, and zero when the correct value would underflow.

       The and functions return NaN when x is less than or equal to zero or when the correct value would overflow.

       The function returns NaN if x or y is NaN.  When both x and y are zero, 1.0 is returned.  When x is negative and y is not an  integer,  NaN
       is returned.  If x is zero and y is negative, -HUGE_VAL is returned.

       The function returns NaN when x is negative.

See Also
       math(3m)

								       RISC								   exp(3m)
All times are GMT -4. The time now is 08:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy