trusted
183
edits
(Created page with "{{Built-in|Magnitude|<nowiki>|</nowiki>}} or '''Absolute Value''' is a monadic scalar function which gives the absolute value of a real or...") |
No edit summary |
||
Line 14: | Line 14: | ||
The magnitude of any number is a non-negative real number. | The magnitude of any number is a non-negative real number. | ||
For real numbers, the magnitude equals the original number | For real numbers, the magnitude equals the original number [[times]] (or [[Divide|divided]] by, for non-zero numbers) its [[Signum|sign]]. | ||
<source lang=apl> | <source lang=apl> | ||
v←0 1E¯100 20 1E300 ¯1E¯100 ¯20 ¯1E300 | |||
(|v)≡v××v | |||
1 | |||
(|v)=v÷×v | |||
0 1 1 1 1 1 1 | |||
</source> | </source> | ||
Line 23: | Line 27: | ||
<source lang=apl> | <source lang=apl> | ||
⍝ | Dist←{0.5*⍨+.×⍨9 11○⍵} ⍝ Square root of square sum of real and imaginary parts | ||
Dist¨ 0 1J2 ¯3J4 | |||
0 2.236067977 5 | |||
|0 1J2 ¯3J4 | |||
0 2.236067977 5 | |||
</source>{{Works in|[[Dyalog APL]]}} | </source>{{Works in|[[Dyalog APL]]}} | ||
Line 29: | Line 37: | ||
<source lang=apl> | <source lang=apl> | ||
(⊢ ≡ ××|) 0 1 1E¯300 ¯2.5 0J3.5 ¯3J¯4 | |||
1 | |||
</source>{{Works in|[[Dyalog APL]]}} | </source>{{Works in|[[Dyalog APL]]}} | ||