* Updated license
* Removed extraneous tabs * Implemented lldiv (#2688) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27250 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
e969748a3d
commit
29fd670a1b
@ -1,8 +1,9 @@
|
||||
/*
|
||||
* Copyright 2002-2005, Haiku Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _DIV_T_H_
|
||||
#define _DIV_T_H_
|
||||
/*
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int quot;
|
||||
|
@ -14,10 +14,10 @@ div_t
|
||||
div(int numerator, int denominator)
|
||||
{
|
||||
div_t val;
|
||||
|
||||
|
||||
val.quot = numerator / denominator;
|
||||
val.rem = numerator - denominator * val.quot;
|
||||
|
||||
|
||||
if (val.rem > 0 && val.quot < 0) {
|
||||
val.rem -= denominator;
|
||||
++val.quot;
|
||||
@ -31,10 +31,27 @@ ldiv_t
|
||||
ldiv(long numerator, long denominator)
|
||||
{
|
||||
ldiv_t val;
|
||||
|
||||
|
||||
val.quot = numerator / denominator;
|
||||
val.rem = numerator - denominator * val.quot;
|
||||
|
||||
|
||||
if (val.rem > 0 && val.quot < 0) {
|
||||
val.rem -= denominator;
|
||||
++val.quot;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
lldiv_t
|
||||
lldiv(long long numerator, long long denominator)
|
||||
{
|
||||
lldiv_t val;
|
||||
|
||||
val.quot = numerator / denominator;
|
||||
val.rem = numerator - denominator * val.quot;
|
||||
|
||||
if (val.rem > 0 && val.quot < 0) {
|
||||
val.rem -= denominator;
|
||||
++val.quot;
|
||||
|
Loading…
Reference in New Issue
Block a user