17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

div( ) ldiv( )<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

Function:<br />

Availability:<br />

Requires:<br />

Examples:<br />

idiv=div(num, denom)<br />

ldiv =ldiv(lnum, ldenom)<br />

num and denom are signed integers.<br />

num is the numerator and denom is the denominator.<br />

lnum and ldenom are signed longs<br />

lnum is the numerator and ldenom is the denominator.<br />

idiv is a structure of type div_t and lidiv is a structure of type ldiv_t. The div<br />

function returns a structure of type div_t, comprising of both the quotient and<br />

the remainder. The ldiv function returns a structure of type ldiv_t, comprising of<br />

both the quotient and the remainder.<br />

The div and ldiv function computes the quotient and remainder of the division<br />

of the numerator by the denominator. If the division is inexact, the<br />

resulting quotient is the integer or long of lesser magnitude that is the nearest<br />

to the algebraic quotient. If the result cannot be represented, the behavior is<br />

undefined; otherwise quot*denom(ldenom)+rem shall equal num(lnum).<br />

All devices.<br />

#INCLUDE <br />

div_t idiv;<br />

ldiv_t lidiv;<br />

idiv=div(3,2);<br />

//idiv will contain quot=1 and rem=1<br />

lidiv=ldiv(300,250);<br />

//lidiv will contain lidiv.quot=1 and lidiv.rem=50<br />

Example Files:<br />

Also See:<br />

None<br />

None<br />

enable_interrupts( )<br />

Syntax:<br />

Parameters:<br />

Returns:<br />

Function:<br />

enable_interrupts (level)<br />

level is a constant defined in the devices *.h file.<br />

undefined.<br />

This function enables the interrupt at the given level. An interrupt procedure<br />

174

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!