Does anyone have a simple way of doing floating point ("fp") division? For example, if I divide 3 by 5, I can get 0.6. The built-in calc (`bc`) will perform fp multiplication, but not division, at least not straight-up (i.e., starting bc and just typing in 3/5).
I am trying to do this using... (1 Reply)
hi, :)
I have a file like this
10.456
123.567
456.876
234.987
........
.......
What i want to do is ia have to add all those numbers and put the result in some other file.
Any help pls.
cheers
RRK (8 Replies)
Hi all!
Hi all!
I am working with a problem to find the smallest floating point number that can be represented.
I am going in a loop ,stating with an initial value of 1.0 and then diving it by 10 each time thru the loop.
So the first time I am getting o.1 which I wanted.But from the next... (4 Replies)
Hello,
i have some variables say:
x=1.4
y=3.7
I wish to round off these values to :
x = 2 (after rounding off)
y = 4 (after rounding off)
I am stuck.
Please help. (7 Replies)
Hi,
see the simple code below
double i;
i=8080.9940;
printf(" val :%.30f\n",i);
output i m getting is
val :8080.993999999999700000000000000
when i m expecting
val :8080.9940
what happens?how can i avoid it?
thanks... (2 Replies)
Hi,
I have linux fedora 4 ver., 2.6 kernal. And qmail & mysql & samba servers are already configured on this server.
When I try to install any package like squidguard ,dansguardian,webmin,rsnapshots with command rpm -ivh . It is giving error as “Floating point exception"
Snap View is... (3 Replies)
Hi,
I am compiling "HelloWorld" C progam on 32-bit CentOS and i want to execute it on 64-bit CentOS architecture.
For that i copied the a.out file from 32-bit to 64-bit machine, but while executing a.out file on 64bit machine I am getting "Floating point exception error".
But we can run... (3 Replies)
is it not possible to simply di aritmetic without using bc or awk
i have tried folllowing operatrions but they support only integer types plz suggest me code for floating using values stored in the variables.the ans i get is integer and if i input floating values i get error numeric constant... (6 Replies)
Discussion started by: sumit the cool
6 Replies
LEARN ABOUT PLAN9
add
ADD(2) System Calls Manual ADD(2)NAME
add, sub, mul, div, raddp, rsubp, rmul, rdiv, rshift, inset, rcanon, eqpt, eqrect, ptinrect, rectinrect, rectXrect, rectclip, Dx, Dy, Pt,
Rect, Rpt - arithmetic on points and rectangles
SYNOPSIS
#include <u.h>
#include <libc.h>
#include <libg.h>
Point add(Point p, Point q)
Point sub(Point p, Point q)
Point mul(Point p, int a)
Point div(Point p, int a)
Rectangle raddp(Rectangle r, Point p)
Rectangle rsubp(Rectangle r, Point p)
Rectangle rmul(Rectangle r, int a)
Rectangle rdiv(Rectangle r, int a)
Rectangle rshift(Rectangle r, int a)
Rectangle inset(Rectangle r, int n)
Rectangle rcanon(Rectangle r)
int eqpt(Point p, Point q)
int eqrect(Rectangle r, Rectangle s)
int ptinrect(Point p, Rectangle r)
int rectinrect(Rectangle r, Rectangle s)
int rectXrect(Rectangle r, Rectangle s)
int rectclip(Rectangle *rp, Rectangle b)
int Dx(Rectangle r)
int Dy(Rectangle r)
Point Pt(int x, int y)
Rectangle Rect(int x0, int y0, int x1, int y1)
Rectangle Rpt(Point p, Point q)
DESCRIPTION
The functions Pt, Rect and Rpt construct geometrical data types from their components. These are implemented as macros.
Add returns the Point sum of its arguments: Pt(p.x+q.x, p.y+q.y). Sub returns the Point difference of its arguments: Pt(p.x-q.x, p.y-q.y).
Mul returns the Point Pt(p.x*a, p.y*a). Div returns the Point Pt(p.x/a, p.y/a).
Raddp returns the Rectangle Rect(add(r.min, p), add(r.max, p)); rsubp returns the Rectangle Rpt(sub(r.min, p), sub(r.max, p)). Rmul
returns the Rectangle Rpt(mul(r.min,a), mul(r.max,a)); Rdiv returns the Rectangle Rpt(div(r.min,a), div(r.max,a)).
Rshift returns the rectangle r with all coordinates either left-shifted or right-shifted by a, depending on whether a is positive or nega-
tive, respectively.
Inset returns the Rectangle Rect(r.min.x+n, r.min.y+n, r.max.x-n, r.max.y-n).
Rcanon returns a rectangle with the same extent as r, canonicalized so that min.x <= max.x, and min.y <= max.y.
Eqpt compares its argument Points and returns 0 if unequal, 1 if equal. Eqrect does the same for its argument Rectangles.
Ptinrect returns 1 if p is a point within r, and 0 otherwise.
Rectinrect returns 1 if all the pixels in r are also in s, and 0 otherwise.
RectXrect returns 1 if r and s share any point, and 0 otherwise.
Rectclip clips in place the Rectangle pointed to by rp so that it is completely contained within b. The return value is 1 if any part of
*rp is within b. Otherwise, the return value is 0 and *rp is unchanged.
The functions Dx and Dy give the width (x) and height (y) of a Rectangle. They are implemented as macros.
SOURCE
/sys/src/libg
SEE ALSO graphics(2)ADD(2)