# div(3) [ultrix man page]

```div(3)							     Library Functions Manual							    div(3)

Name
div, ldiv - integer division

Syntax
#include <stdlib.h>

div_t div(numer, denom)
int numer;
int denom;

ldiv_t ldiv(numer, denom)
long numer;
long denom;

Description
The and functions return the quotient and remainder of the division of the numerator numer by the denominator denom.

The return types div_t and ldiv_t are defined, in stdlib.h, as follows:

typedef struct {
int  quot;	/* quotient */
int  rem; /* remainder */
}	 div_t; 	/* result of div() */

typedef struct {
long quot;	/* quotient */
long rem; /* remainder */
}	 ldiv_t;	/* result of ldiv() */

Restrictions
If division by zero is attempted, the behavior of and is undefined.

div(3)```

## Check Out this Related Man Page

```div(3C) 						   Standard C Library Functions 						   div(3C)

NAME
div, ldiv, lldiv - compute the quotient and remainder

SYNOPSIS
#include <stdlib.h>

div_t div(int numer, int denom);

ldiv_t ldiv(long int numer, long int denom);

lldiv_t lldiv(long long numer, long long denom);

DESCRIPTION
The div() function computes the quotient and remainder of the division of the numerator numer by the denominator denom. It provides a well-
defined semantics for the signed integral division and remainder operations, unlike the implementation-defined semantics  of  the  built-in
operations.    The  sign  of the resulting quotient is that of the algebraic quotient, and if the division is inexact, the magnitude of the
resulting quotient is the largest integer less than the magnitude of the algebraic quotient. If the  result  cannot  be	 represented,  the
behavior is undefined; otherwise, quotient * denom + remainder will equal numer.

The  ldiv()  and lldiv() functions are similar to div(), except that the arguments and the members of the returned structure are different.
The ldiv() function returns a structure of type ldiv_t and has type long int.  The lldiv() function returns a structure of type lldiv_t and
has type long long.

RETURN VALUES
The div() function returns a structure of type div_t, comprising both the quotient and remainder:

int   quot;   /*quotient*/
int   rem;    /*remainder*/

The  ldiv()  function returns a structure of type ldiv_t and lldiv() returns a structure of type lldiv_t, comprising both the  quotient and
remainder:

long int   quot;   /*quotient*/
long int   rem;	  /*remainder*/

ATTRIBUTES
See attributes(5) for descriptions of the following attributes:

+-----------------------------+-----------------------------+
|      ATTRIBUTE TYPE	     |	    ATTRIBUTE VALUE	   |
+-----------------------------+-----------------------------+
|Interface Stability	     |Standard			   |
+-----------------------------+-----------------------------+
|MT-Level		     |MT-Safe			   |
+-----------------------------+-----------------------------+

attributes(5), standards(5)

SunOS 5.10							    24 Jul 2002 							   div(3C)```
Man Page

## fun with tar

ok, i've figured out my problem with distributed, in Solaris GUI if you click on a tar file it will untar it for you, using paramiters I don't know. now, I've got a tar file in / called dnetc-solaris26-x86.tar i want to install it to the "/Veitch" directory how exactly do I use the tar...

## division operation in shell script

Hi guys I am trying to divide 2 variables that I got during the execution of script, but I unable to divide the variables. pls help. Hers is the code. num_tasks=`sqlplus -s batch_user/batch_user@acsblest << EOF1 set heading off SET FEEDBACK OFF SET PAGESIZE 0 SET LINESIZE 900 select...

## Round with division command

Hi I want to create a list of percentages but the shell script is bugging me. If if I want to resolve the percentage of the quota used I get 0 because the schell script rounds by default. Example w1=860 w2=1024 w3=\$(((\$w1/\$w2)*100)) Echo \$w3 gives 0 When I divide w1 by w2 the result...

## Problem in division

hi I am having two variables namely a=7 & b=8. I have to subtract these two variables. I am using the command c=`expr \$a / \$b` When I check the value of c, it comes out to be zero. Please help. Regards Rochit

## divided by 0 problem

Hi! i have a new shell script that will compute for a value... a = b/(b+c) c = d/(d+e) print b" "a" "d" "c but there will be an instance that either b+c or d+e will be "0".... if b+c or d+e is "0" it will print "#NA#... pls help me... thanks!

## Scuba Divers on the Site?

Hey! I used to dive a lot and got my PADI Open Water Diver certification many years ago. Now, I'm thinking about getting back into diving and taking a PADI Advanced Open Water diver course after a few fun refresher dives. Any divers on the site?

## awk: division by zero

I received error "awk: division by zero" while executing the following statement. SunOS 5.10 Generic_142900-15 sun4us sparc FJSV,GPUZC-M echo 8 | awk 'END {printf ("%d\n",NR/\$1 + 0.5);}' file1.lst awk: division by zero Can someone provide solution? Thanks Please use code...

## awk division error - 0

input 0 0 9820373 2069 0 0 11485482 awk '{print (\$1/\$3) / (\$4/\$7)}' input error Is there any way to fix this problem ?

## Dividing a column by it's first number

Hi! Is there an easy way (maybe using awk??) to divide the values of one column of the file by it's first entry.. If I have a column: 3 4 5 6 7 I would like to divide it by 3. I want to do this for more than 100 files, so it wouldn't be practical to open file by file and...

## Port VPM Decompression Algorithm to PHP and then to Dive Computer

Hello! I'm about to embark on a new project to port the VPM (Variable Permability Model) for decompression diving from some old BASIC code (attached, "VPM.txt") to PHP. Then, I plan to create a plugin for this site where folks can run VPM on the web. Then, I plan to improve VPM based on...

## Concatenate text between patterns in individual strings

In any given file, wherever a certain data block exists I need to concatenate the values(text after each "=" sign) from that block. in that block. The block starts and ends with specific pattern, say BEGIN DS and END DS respectively. The block size may vary. A file will have multiple such blocks....

## 12. Solaris

Hi There is an application installed on a server, that has a unique login account, but many users are using it with the same login name! How can we overcame this by creating individual accounts for the same application login account?

## Subtract coloumn3 with coloumn 4 & divide it

I have a file called testfile as per my requirement I want to subtract coloumn3 with coloumn 4 & divide it with (1024*1024*1024)) and finally if the value is greater than 1.5 then it should be printed formula looks like this ((\$3-\$4)/(1024*1024*1024)) more testfile 2015-01-19 00:12:32...

## Posts Converted to Divs - Overflow Works - Now Testing

Hey, Success! I have converted the posts (each of the main posts) from table tags to div tags and the problem with the scroll bar and code tags is fixed, as I predicted (Yay!). Now I'm testing this (only I see the new results because the new code is restricted to my userid) but I would...