summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/code_generators/generate_umath.py2
-rw-r--r--numpy/core/src/umath/loops.c.src12
2 files changed, 4 insertions, 10 deletions
diff --git a/numpy/core/code_generators/generate_umath.py b/numpy/core/code_generators/generate_umath.py
index 97172ad29..4aea685df 100644
--- a/numpy/core/code_generators/generate_umath.py
+++ b/numpy/core/code_generators/generate_umath.py
@@ -255,7 +255,7 @@ defdict = {
'true_divide' :
Ufunc(2, 1, One,
docstrings.get('numpy.core.umath.true_divide'),
- TD('bBhH', out='f'),
+ TD('bBhH', out='d'),
TD('iIlLqQ', out='d'),
TD(flts+cmplx),
TD(O, f='PyNumber_TrueDivide'),
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index 10cfa8716..5c9e2bfd0 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -643,15 +643,9 @@ NPY_NO_EXPORT void
@S@@TYPE@_true_divide(char **args, intp *dimensions, intp *steps, void *NPY_UNUSED(func))
{
BINARY_LOOP {
- const @s@@type@ in1 = *(@s@@type@ *)ip1;
- const @s@@type@ in2 = *(@s@@type@ *)ip2;
- if (in2 == 0) {
- generate_divbyzero_error();
- *((@ftype@ *)op1) = 0;
- }
- else {
- *((@ftype@ *)op1) = (@ftype@)in1 / (@ftype@)in2;
- }
+ const double in1 = (double)(*(@s@@type@ *)ip1);
+ const double in2 = (double)(*(@s@@type@ *)ip2);
+ *((double *)op1) = in1/in2;
}
}