Questions tagged [math]
For questions about designing and implementing mathematical functions or operations in a programming language.
4 questions from the last 365 days
6
votes
0
answers
181
views
In C/C++, why does the logarithm of zero have a well-defined imaginary part?
By the C standard and the C++ standard:
$\log(0+0i) = -\infty+0 i$.
$\log(0-0i) = -\infty-0 i$.
$\log(-0+0i) = -\infty+\pi i$.
$\log(-0-0i) = -\infty-\pi i$.
However, if the floating-point complex ...
9
votes
0
answers
195
views
How to usefully implement trig (and other irrational functions) on rational primitives
Based on my limited experience, most languages that have rationals as their primary number type simply do not have built-ins for sin,...
6
votes
6
answers
812
views
What programming languages contain a built-in imaginary data type?
Many languages like R, Julia, and Python store imaginary numbers as a complex number with a 0 valued real component. We may see this with the following R code:
...
8
votes
1
answer
574
views
Why is truncated or non-Euclidean division/modulo the norm?
Related to, but not the same question: Distinguishing modulo (Euclidean division) from remainder
There are multiple ways a modulo operation can be performed. Most implementations, in C, for example, ...