Changeset 8e7c9fe in mainline for uspace/lib/math/generic/mod.c
- Timestamp:
- 2014-09-12T03:45:25Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c53b58e
- Parents:
- 3eb0c85 (diff), 105d8d6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/math/generic/mod.c
r3eb0c85 r8e7c9fe 1 1 /* 2 * Copyright (c) 20 06 Jakub Jermar2 * Copyright (c) 2014 Martin Decky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup ppc32ddi29 /** @addtogroup libmath 30 30 * @{ 31 31 */ … … 33 33 */ 34 34 35 #include <ddi/ddi.h> 36 #include <proc/task.h> 37 #include <typedefs.h> 35 #include <math.h> 36 #include <mod.h> 38 37 39 /** Enable I/O space range for task.38 /** Double precision modulo 40 39 * 41 * Interrupts are disabled and task is locked.40 * Calculate the modulo of dividend by divisor. 42 41 * 43 * @param task Task. 44 * @param ioaddr Startign I/O space address. 45 * @param size Size of the enabled I/O range. 42 * This is a very basic implementation that uses 43 * division and multiplication (instead of exact 44 * arithmetics). Thus the result might be very 45 * imprecise (depending on the magnitude of the 46 * arguments). 46 47 * 47 * @return 0 on success or an error code from errno.h. 48 * @param dividend Dividend. 49 * @param divisor Divisor. 50 * 51 * @return Modulo. 48 52 * 49 53 */ 50 int ddi_iospace_enable_arch(task_t *task, uintptr_t ioaddr, size_t size)54 double double_mod(double dividend, double divisor) 51 55 { 52 return 0; 56 // FIXME: replace with exact arithmetics 57 58 double quotient = trunc(dividend / divisor); 59 60 return (dividend - quotient * divisor); 53 61 } 54 62
Note:
See TracChangeset
for help on using the changeset viewer.