Trigonometric functions: Difference between revisions
Content added Content deleted
(Added FreeBASIC) |
No edit summary |
||
Line 3,494: | Line 3,494: | ||
0,785398 45,000000 |
0,785398 45,000000 |
||
0,785398 45,000000</pre> |
0,785398 45,000000</pre> |
||
===A More "PowerShelly" Way=== |
|||
I would send the output as an array of objects containing the (<code>[double]</code>) properties: '''Radians''' and '''Degrees'''. |
|||
Notice the difference between the last decimal place in the first two objects. Additionally, the output is an array of objects rather than an array of strings. |
|||
<lang PowerShell> |
|||
$radians = [Math]::PI / 4 |
|||
$degrees = 45 |
|||
[PSCustomObject]@{Radians=[Math]::Sin($radians); Degrees=[Math]::Sin($deg * [Math]::PI / 180)} |
|||
[PSCustomObject]@{Radians=[Math]::Cos($radians); Degrees=[Math]::Cos($deg * [Math]::PI / 180)} |
|||
[PSCustomObject]@{Radians=[Math]::Tan($radians); Degrees=[Math]::Tan($deg * [Math]::PI / 180)} |
|||
[double]$tempVar = [Math]::Asin([Math]::Sin($radians)) |
|||
[PSCustomObject]@{Radians=$tempVar; Degrees=$tempVar * 180 / [Math]::PI} |
|||
[double]$tempVar = [Math]::Acos([Math]::Cos($radians)) |
|||
[PSCustomObject]@{Radians=$tempVar; Degrees=$tempVar * 180 / [Math]::PI} |
|||
[double]$tempVar = [Math]::Atan([Math]::Tan($radians)) |
|||
[PSCustomObject]@{Radians=$tempVar; Degrees=$tempVar * 180 / [Math]::PI} |
|||
</lang> |
|||
{{Out}} |
|||
<pre> |
|||
Radians Degrees |
|||
------- ------- |
|||
0.707106781186547 0.707106781186547 |
|||
0.707106781186548 0.707106781186548 |
|||
1 1 |
|||
0.785398163397448 45 |
|||
0.785398163397448 45 |
|||
0.785398163397448 45 |
|||
</pre> |
|||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |