Math.max and Math.min only accept two parameters
- Dominant language
- JavaScript
- Stars
- 15.5k
- Forks
- 663
- PR merge metrics
- No merged PRs in 30d
Description

## *What* is wrong?
Using `Math.max` with more than two parameters causes the GPU kernel build to fail.
## *How* do we replicate the issue?
```
const gpu = new GPU({ mode: 'gpu' });
const kernel = gpu.createKernel(function() {
return Math.max(0, 1, 2);
}).setOutput([1]);
kernel();
```
And observe the output error
`gpu-browser.js:14913 Uncaught Error: Error compiling fragment shader: ERROR: 0:457: 'max' : no matching overloaded function found`. Replacing `0, 1, 2` with `0, 1` (or any other two numbers) leads to the function behaving as expected. The same is true of `Math.min`.
JS Fiddle: [https://jsfiddle.net/TomWyllie/opdg95kb/](https://jsfiddle.net/TomWyllie/opdg95kb/)
GPU.js 2.9.4
GPU: NVIDIA GeForce GTX 1060 3GB
Nvidia Driver 446.14
Google Chrome Version 83.0.4103.97 (Official Build) (64-bit)
Windows 10
## *How* important is this (1-5)?
2, it's very easy (but pretty messy) to workaround by using `Math.max(x, Math.max(y, Math.max(z, t)));` or similar, but that is pretty ugly. My understanding is that the [spec](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) allows arbitrarily many parameters.
## Other Comments
I'm beginning to think there might be something deeper wrong with GPU.js on my machine given this issue and the other I filed several days ago (#617) must be very common use cases and surely lots of other people would be having these same problems... any thoughts appreciated.
Contributor guide
Assessment
This issue has not been assessed yet.