opendylan icon indicating copy to clipboard operation
opendylan copied to clipboard

log(x) only works for floats

Open cgay opened this issue 5 years ago • 2 comments

transcendentals, math

log is documented to accept <real> but in fact only has methods for floats. This means that logn doesn't work on integers either since it just calls log.

I lean toward providing convenience methods that convert integer args to <double-float>, as Python seems to allow, as long as it doesn't add run-time cost for the normal case. Go only allows float64 args.

cgay avatar Nov 27 '20 03:11 cgay

Methods that would do this were previously provided, but we removed them in 4b7cb6ff6f3ab134dbd9c29f94afa2dd6fd72f26. At the time we decided it would be best to explicitly do the cast (choosing whether you wanted to do the computation with <single-float> or <double-float>) rather than defaulting to <single-float> .

housel avatar Nov 27 '20 17:11 housel

ok. I'm not a big fan of that approach, especially since we can't get a good compiler warning for passing integers, but I guess I'll close this after making minor adjustments to the docs.

cgay avatar Nov 27 '20 20:11 cgay