Floating point does not always represent some numbers precisely
0.5 and 0.25 are simple binary fractions of 1, floating point will represent it perfectly as long as it has 2+ bits of fraction. For 32-bit floats, anything inside +/-2 million will work perfectly.
Computationally speaking, this is the most direct method: Multiply by 4, strip off decimals, divide by 4.
Last edited by Corona688; 09-26-2014 at 03:04 PM..
Hi All,
How we can handle decimals in (Float) in UNIX.
a=73
b=5
c=`expr a / b`
i am getting 14 but i need full 14.6 .
Can any one help me pls? (1 Reply)
I need to get 15% of the variable exer1 to be added to other exercises
so far, i've got
exer1=$1
aver=`expr $exer \* .15`
but i keep getting an error that an integer value was expected. Is there anyway around this? (1 Reply)
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)
Hello,
I want to run a loop with non-integer values (which I know I can't) so I've created a loop of integers and divided it by 10. However, these values are always rounded down to 1 significant figure. How do I get the script to keep and use the decimal value?
My script is as follows
#... (1 Reply)
Hello...
I am new to unix and I am wondering if in a C-shell script , Are we supposed to use only whole numbers........ for example..if a program needs to calculate the average of some numbers........
@ avg = (($1 +$2 + $3)/3)) is returning a whole number.........How can a decimal be achieved... (1 Reply)
Hi I have a large file in which I need to search for certain whole numbers and print the whole line. I'm currently trying this via command line using grep but grep is also matching the decimal values and i just want to return the matching whole numbers (the entire line)
Example
File
ddggg ... (7 Replies)
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)
I am trying to get date to display decimal
Desired output 1350386096256.12
I know this can be done with printf, but are not able to make it work.
I have tested this and many otherprintf "%.2f" $(($(date +%s%N)/1000000)) (8 Replies)
Hello,
i'm new in python. Consider that i have this function that read me some data from a serial :
def GetData():
line = open(serialx).read()
hash = line.find("#")
when = line
count = line
# print when, count, line
return (float(when), int(count))
it gives me the result... (2 Replies)
Hi Gurus,
I have below sample file, I need find the line which 2rd field has more than 2 decimals.
in sample file, I need to find xyz, 123456.789
abc, 1234.45, def
xyz, 123456.789, xxx
bce, 1234.34, xxx
thanks in advance (13 Replies)
Discussion started by: ken6503
13 Replies
LEARN ABOUT SUSE
floorf
FLOOR(3) Linux Programmer's Manual FLOOR(3)NAME
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 http://www.kernel.org/doc/man-pages/.
2008-10-06 FLOOR(3)