…without using any operator/function besides addition (+
), subtraction (-
), multiplication (*
), division (/
), modulo (%
), exponent/power pow()
or any of the standard C bitwise operators (<<, >>, ~, &, |, ^
) or unary operators (—, ++
) or assignment/comparison operators (=, ==
).
If these symbols represent a different operation in your chosen language, go with the spirit of the question and don't use them.
Rules:
- You cannot use any mathematical functions your language might offer (Mathematica, looking at you.)
- You cannot use any operator besides the bitwise operators or the arithmetic operators listed above.
- Your output should be a float and be correct to at least 2 decimal places when truncated/rounded.
- You can use constants your language's standard libraries might provide.
- You can hardcode the values, but your program should work correctly for all floats (up to 2 decimal places) between
0
and2π
;
This is code-golf, so the shortest answer wins.
Example:
Input: 3.141592653 / 2
Output: 1.00xxxxxx…
Please also post an ungolfed version of your code.
<
,>
, or^
meaning to-the-power-of rather than bitwise-XOR. Whether you prefer to comment on those answers and inform their submitters that they're invalid, or to edit the question to permit them, you could make things a lot clearer by listing the operators by name, not symbol in some unspecified language, and by grouping them with some kind of title or label (comparison, bitwise, arithmetic, assignment). \$\endgroup\$exp
is the exponent operator (or exponentiation) and not the exponential function. \$\endgroup\$