lldiv.gml

来自「开放源码的编译器open watcom 1.6.0版的源代码」· GML 代码 · 共 62 行

GML
62
字号
.func lldiv
#include <stdlib.h>
lldiv_t lldiv( long long int numer, 
               long long int denom );

typedef struct {
    long long int quot; /* quotient */
    long long int rem;  /* remainder */
} lldiv_t;
.funcend
.*
.desc begin
The &func
function calculates the quotient and remainder of the division of the
numerator
.arg numer
by the denominator
.arg denom.
.desc end
.*
.return begin
The &func function returns a structure of type
.kw lldiv_t
that contains the fields
.kw quot
and
.kw rem
.ct,
which are both of type
.id long long int.
.return end
.*
.see begin
.seelist ldiv div imaxdiv
.see end
.*
.exmp begin
#include <stdio.h>
#include <stdlib.h>

void print_time( long long int ticks )
{
    lldiv_t sec_ticks;
    lldiv_t min_sec;

    sec_ticks = lldiv( ticks, 100 );
    min_sec   = lldiv( sec_ticks.quot, 60 );
    printf( "It took %lld minutes and %lld seconds\n",
            min_sec.quot, min_sec.rem );
}
.exmp break
void main( void )
{
    print_time( 73495132 );
}
.exmp output
It took 12249 minutes and 11 seconds
.exmp end
.*
.class ISO C99
.system

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?