g | x | w | all
Bytes Lang Time Link
031AWK250321T170720Zxrs
032Raku Perl 6 rakudo250321T165518Zxrs
074Tcl181227T234859Zsergiol
035Scala150726T035240Zgilad ho
044Matlab150725T134139ZLuis Men
025dc150725T211405ZDigital
026J150725T092848ZLegendre
017Pyth150725T082856Zisaacg
044PHP150725T064641Zrink.att
018Pyth150725T062121ZgrovesNL
043JavaScript ES6150725T063634Zrink.att
021CJam150725T063515ZPeter Ta
030Pyth 25150725T061440ZWinny
034Python 2150725T060627ZSp3000
035Python 2150725T055124Zxnor
031Mathematica150725T055406Zalephalp

AWK, 31 bytes

$0=90-sqrt(($0%180-90)^2)" deg"

Attempt This Online!

AWK doesn't have built min or abs.

Raku (Perl 6) (rakudo), 32 bytes

->\x{say x%180 min-x%180," deg"}

Attempt This Online!

Seemed to be tightest algo around.

Tcl, 74 bytes

proc R a {puts [expr [set a $a%360]>90?$a>270?360-$a:abs($a-180):$a]\ deg}

Try it online!

Scala, 40 35 Characters

(a:Int)⇒s"${90-(a%180-90).abs} deg"

Matlab, 44

Using an anonymous function:

f=@(x)[num2str(min(mod([x -x],180))) ' deg']

Example:

>> f=@(x)[num2str(min(mod([x -x],180))) ' deg']
f = 
    @(x)[num2str(min(mod([x,-x],180))),' deg']

>> f(70)
ans =
70 deg

>> f(210)
ans =
30 deg

>> f(-1000)
ans =
80 deg

dc, 25

90?90+d*v180%-d*vn[ deg]p

Note dc uses _ as a -ve sign instead of -.

Test output:

$ for test in 70 135 210 _60 91 610 _1000; do dc -e'90?90+d*v180%-d*vn[ deg]p' <<< $test ; done
70 deg
45 deg
30 deg
60 deg
89 deg
70 deg
80 deg
$

J, 26 bytes

m=:180&|
' deg',~m@-":@<.m

Same as xnor's method.

Pyth, 17 bytes

+hS%R180,Q_Q" deg

Coincidentally, this is equivalent to @xnor's answer.

Try it online.

PHP, 44 bytes

Takes one command line parameter. Again PHP suffers from the same issue as JavaScript.

<?=90-abs(($argv[1]%180+180)%180-90)+' deg';

Using the canonical solution requires 53 bytes (the degrees and radians conversion takes a lot of characters):

<?=rad2deg(abs(asin(sin(deg2rad($argv[1])))))+' deg';

Pyth, 18 bytes

+.a-%+QK90yKK" deg

Try it online.

JavaScript (ES6), 43 bytes

Similar to Sp3000's answer, though the modulo is quite lengthy due to the behaviour in JavaScript.

f=x=>90-Math.abs((x%180+180)%180-90)+' deg'

Demo

Code is rewritten in ES5 for browser compatibility:

function f(x){return 90-Math.abs((x%180+180)%180-90)+' deg'}

// Snippet stuff
console.log = function(x){document.body.innerHTML += x + '<br>'};
[70,135,210,-60,91,610,-1000].map(function(v){console.log(f(v))});

CoffeeScript, 45 bytes

f=(x)->90-Math.abs((x%180+180)%180-90)+' deg'

CJam (21 bytes)

180qd1$%z_@@-e<" deg"

Online demo

Pyth 25 30 bytes

Painfully uncreative solution, using trig functions. Permalink

+.R.t.a.t.t.tQ7Z3 6?%Q1Q0" deg

Any suggestions welcome.

Python 2, 34 bytes

lambda x:`90-abs(x%180-90)`+' deg'

Using "%d deg" string formatting would be longer because of the needed parentheses.

Python 2, 35

lambda x:`min(x%180,-x%180)`+' deg'

The smaller of the angle and its negative modulo 180. Effectively converts the angle to the range from 0 to 180 and takes the distance to the closer of the endpoints. Note that -x%180 groups as (-x)%180.

Same length with string formatting for Python 3:

lambda x:'%d deg'%min(x%180,-x%180)

Mathematica, 22 31

ToString@Abs@Mod[#,180,-90]deg&