Visit Our UNIX and Linux User Community

Full Discussion: FLOOR Func
Top Forums Shell Programming and Scripting FLOOR Func Post 302141001 by user_prady on Wednesday 17th of October 2007 06:16:52 AM
Old 10-17-2007
Originally Posted by user_prady
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(-1.1) =-2
floor(-1.9) = -2
floor(-2.0) = -2
floor(-2.1) = -3
floor(-2.9) = -3

If there does not exist in awk script please help me some tricks to do it ...

Thanks in advance..

GOT the answer

I made a func like below

function vint(y){
if (y < 0){
if(int(y) == y )
return int(y)
return int(y)-1
return int(y)

Thank you very much..

This User Gave Thanks to user_prady For This Post:
Test Your Knowledge in Computers #504
Difficulty: Medium
Typically, programs operate in a reverse-linear flow of control.
True or False?

7 More Discussions You Might Find Interesting

1. Programming

request_irq func. header file?

I try to compile program which use request_irq function declarated in linux/sched.h but it bring a lot of errors relating to include directives in sched.h. I try on Mandrake7.2 and RedHat7.2 but result same. A lot of thanks for your answers. (2 Replies)
Discussion started by: ppphah
2 Replies

2. Programming

difference between int ** func() and int *& func()

What is the difference between int** func() and int*& func(). Can you please explain it with suitable example. Thanks, Devesh. (1 Reply)
Discussion started by: devesh
1 Replies

3. Shell Programming and Scripting

Utilizing func keys in scripts

I would like to have the function keys available to me in my scripts. Anyone have any ideas on how to map these to functionality I design? :confused: (3 Replies)
Discussion started by: fjjlee
3 Replies

4. Red Hat

Video: Spotlight on FUNC

</p>Download this video: Ogg Theora] FUNC is the brainchild of Michael DeHaan, Adrian Likins, Seth Vidal, and Greg DeKoenigsberg. In this edition of Spotlight On, Michael, Adrian, and Seth discuss how FUNC makes it easy to write commands across large numbers of machines remotely and... (0 Replies)
Discussion started by: Linux Bot
0 Replies

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

6. Programming

Round floor behavior

Hello, My round and floor functions in C program behaves weird. Can someone help resolve the issue.. fprintf( fp, "ROUND TEST VARIABLE 11686776.000000 %d\n", round(11686776.000000)); fprintf( fp, "ROUND TEST VARIABLE 1168677.000000 %d\n", round(1168677.000000)); fprintf( fp, "FLOOR... (3 Replies)
Discussion started by: anijan
3 Replies

7. UNIX for Beginners Questions & Answers


Hello, I have a T5220 server, which is out of support from Oracle support now. Recently I had to reboot it and I am noticing a part failure in its boot logs. Though it comes on login prompt, but I am not able to find,what this part is and if I leave it like this, can it impact anything ? It is... (1 Reply)
Discussion started by: solaris_1977
1 Replies
FLOOR(3)						     Linux Programmer's Manual							  FLOOR(3)

floor, floorf, floorl - largest integral value not greater than argument SYNOPSIS
#include <math.h> double floor(double x); float floorf(float x); long double floorl(long double x); Link with -lm. Feature Test Macro Requirements for glibc (see feature_test_macros(7)): floorf(), floorl(): _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; or cc -std=c99 DESCRIPTION
These functions return the largest integral value that is not greater than x. For example, floor(0.5) is 0.0, and floor(-0.5) is -1.0. RETURN VALUE
These functions return the floor of x. If x is integral, +0, -0, NaN, or an infinity, x itself is returned. ERRORS
No errors occur. POSIX.1-2001 documents a range error for overflows, but see NOTES. CONFORMING TO
C99, POSIX.1-2001. The variant returning double also conforms to SVr4, 4.3BSD, C89. NOTES
SUSv2 and POSIX.1-2001 contain text about overflow (which might set errno to ERANGE, or raise an FE_OVERFLOW exception). In practice, the result cannot overflow on any current machine, so this error-handling stuff is just nonsense. (More precisely, overflow can happen only when the maximum value of the exponent is smaller than the number of mantissa bits. For the IEEE-754 standard 32-bit and 64-bit floating- point numbers the maximum value of the exponent is 128 (respectively, 1024), and the number of mantissa bits is 24 (respectively, 53).) SEE ALSO
ceil(3), lrint(3), nearbyint(3), rint(3), round(3), trunc(3) COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at 2008-10-06 FLOOR(3)

Featured Tech Videos

All times are GMT -4. The time now is 02:23 AM.
Unix & Linux Forums Content Copyright 1993-2020. All Rights Reserved.
Privacy Policy