# ldiv(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.11							    24 Jul 2002 							   div(3C)```
Man Page

## syntax error

hi, i recently changed my shell to bash and now everytime i log in i get this error message. bash: /net/hu5/davidlee/.profile-sun-5: line 48: syntax error near unexpected to ken `fi' bash: /net/hu5/davidlee/.profile-sun-5: line 48: ` if ] then break; fi' any ideas, i´m no expert unix...

## printf and imaxdif_t

i was playing with maxint stuff when i found that i could not find a propper way to do a printf() auf a imaxdiv_t. since nobody seems to use it google found nothing. i tried to find a PRIxy code but no success. example: #include <stdio.h> #include <inttypes.h> int main() { ...

## 3. Shell Programming and Scripting

Quick question. I can not get the context corrert on this code. opendir(DIR, "."); @fileldiv = grep(/l*/,readdir(DIR)); closedir(DIR); I am trying to search all html files within a dir that start with l. Thanks for your help.

## usleep command is not available in SunOS

Hi All, I need usleep command to use in one of my shell script. I am working on SunOS 5.9. Where usleep command is not available. Is there any way to use usleep command in SunOS. Thanks In Advance, chidhu

## Matching and replacing text with case transformations

Hi, I am trying to edit an XML file automatically but my regex and shell script knowledge is very limited. I would appreciate your help fellows. The XML file has this structure: <?xml version="1.0" encoding="UTF-8"?> <map map_file="maps/world.swf" zoom="350%" zoom_x="-115%"...

## How to print range of lines using sed when pattern has special character "["

Hi, My input has much more lines, but few of them are below pin(IDF) { direction : input; drc_pinsigtype : signal; pin(SELDIV6) { direction : input; drc_pinsigtype : ...

## Parse and Join in a text file

I wanted to parse a text file and join in specific format. please suggest me how to get this done.. The output should be in fasta format which consists of lines starting with ID, PT, PA and Sequence. "//" the two slashes are dividing lines between two different sequences. Like...

## Perl script required for processing the data

I have following result.log file (always has 2 lines) which I need to process, cat result.log name.cmd.method,"result","abc","xyz"; name="hello,mine.12345,"&"tree"&" xyz "&" tree "&" xyz", data="way,"&" 1"&"rate-me"&"1"&"rate-me",str="",ret=""; now I need to extract the strings/data as...