Skip to main content

Questions tagged [math]

For questions about designing and implementing mathematical functions or operations in a programming language.

11 votes
4 answers
4k views

I don't see a reason not to implement such floating-point type, like this (Rust-esque pseudocode): ...
Dannyu NDos's user avatar
  • 1,485
3 votes
1 answer
263 views

I've checked the information on cppreference.com and found that there are only 2 and 3 input hypot function. I am wondering why not implement the variadic version ...
JimmyHu's user avatar
  • 165
12 votes
0 answers
491 views

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 ...
Dannyu NDos's user avatar
  • 1,485
9 votes
0 answers
220 views

Based on my limited experience, most languages that have rationals as their primary number type simply do not have built-ins for sin,...
mousetail's user avatar
  • 9,627
6 votes
6 answers
1k views

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: ...
Adam Hyland's user avatar
8 votes
1 answer
855 views

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, ...
CPlus's user avatar
  • 10.5k
5 votes
9 answers
4k views

I'm implementing signed and unsigned integers in my language. They are represented in C as signed long and unsigned long ...
Matheus Moreira's user avatar
31 votes
11 answers
21k views

Note 1: My question is not about the factorial function. It's about "simple math functions" that high-school level pocket calculators can do, but most programming languages cannot do without ...
Nike Dattani's user avatar
11 votes
2 answers
647 views

I'm wondering whether its possible to construct a group where the elements are all possible valid programs, with a small or simple generator set. That way you could have a series of operations you can ...
debater-coder's user avatar
19 votes
3 answers
4k views

In MATLAB (and Octave), the \ (or mldivide) and \. operators are provided with the exact ...
Adám's user avatar
  • 3,317
20 votes
4 answers
6k views

C does not even have M_PI standardized. C++ only added std::numbers::pi very recently. Yes, the fact that this took so long does ...
CPlus's user avatar
  • 10.5k
10 votes
6 answers
4k views

C does not have an exponentiation operator, so that freestanding implementations that lack the math libraries could lack exponentiation as a whole, and still be permissible by the C standard. As a ...
CPlus's user avatar
  • 10.5k
20 votes
5 answers
5k views

Most languages seem to only have sin cos and tan. While the other 3 are just ...
CPlus's user avatar
  • 10.5k
6 votes
2 answers
574 views

sincos() is just a way to compute sin() and cos() at once, possibly at improved performance ...
CPlus's user avatar
  • 10.5k
14 votes
5 answers
2k views

The % operator in most programming language provide a remainder from integer division. When both operands are positive all works as expected. But when the number is ...
CPlus's user avatar
  • 10.5k