aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library.js2
-rwxr-xr-xtests/runner.py5
2 files changed, 5 insertions, 2 deletions
diff --git a/src/library.js b/src/library.js
index 9eae740a..06661d59 100644
--- a/src/library.js
+++ b/src/library.js
@@ -5365,7 +5365,7 @@ LibraryManager.library = {
},
fmaxf: 'fmax',
fmin: function(x, y) {
- return isNaN(x) ? y : isNaN(y) ? x : Math.max(x, y);
+ return isNaN(x) ? y : isNaN(y) ? x : Math.min(x, y);
},
fminf: 'fmin',
fma: function(x, y, z) {
diff --git a/tests/runner.py b/tests/runner.py
index 3967cce7..3f17cf2c 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1368,6 +1368,7 @@ c5,de,15,8a
def test_floatvars(self):
src = '''
#include <stdio.h>
+ #include <math.h>
int main()
{
float x = 1.234, y = 3.5, q = 0.00000001;
@@ -1375,6 +1376,8 @@ c5,de,15,8a
int z = x < y;
printf("*%d,%d,%.1f,%d,%.4f,%.2f*\\n", z, int(y), y, (int)x, x, q);
+ printf("%.2f, %.2f, %.2f, %.2f\\n", fmin(0.5, 3.3), fmin(NAN, 3.3), fmax(0.5, 3.3), fmax(NAN, 3.3));
+
/*
// Rounding behavior
float fs[6] = { -2.75, -2.50, -2.25, 2.25, 2.50, 2.75 };
@@ -1386,7 +1389,7 @@ c5,de,15,8a
return 0;
}
'''
- self.do_run(src, '*1,10,10.5,1,1.2340,0.00*')
+ self.do_run(src, '*1,10,10.5,1,1.2340,0.00*\n0.50, 3.30, 3.30, 3.30\n')
def test_globaldoubles(self):
src = r'''