Abs


 * abs

ALGOL 68
Works with ALGOL 68 Revisions 0 and 1. Tested with algol68g-2.4.1.

File: test_abs.a68 #!/usr/bin/algol68g-full --script # # -*- coding: utf-8 -*- # BOOL bt=TRUE, bf=FALSE; BITS b2=, b4= , b8= , b16= ; CHAR ca="A", cb="B"; SHORT INT sip=SHORT 5, sin=SHORTEN</b> -5; INT</b> ip=5, in=-5; LONG</b> INT</b> lip=LONG</b> 5, lin=LENG</b> -5; REAL</b> rp=, rn= ; COMPL</b> cp3i4=3I</b>4, cn3i4=-3I</b>4; printf(( $"Integer results:"$,$g"="g(-0)"; "$, "bt", ABS</b> bt, "bf", ABS</b> bf, "b2", ABS</b> b2, "b4", ABS</b> b4, "b8", ABS</b> b8, "b16", ABS</b> b16, "ca", <b style="text-transform: lowercase;">ABS</b> ca, "cb", <b style="text-transform: lowercase;">ABS</b> cb, "sip", <b style="text-transform: lowercase;">ABS</b> sip, "sin", <b style="text-transform: lowercase;">ABS</b> sin, "ip", <b style="text-transform: lowercase;">ABS</b> ip, "in", <b style="text-transform: lowercase;">ABS</b> in, "lip", <b style="text-transform: lowercase;">ABS</b> lip, "lin", <b style="text-transform: lowercase;">ABS</b> lin, $l"Real results:"$,$g"="g(-0,1)"; "$, "rp", <b style="text-transform: lowercase;">ABS</b> rp, "rn", <b style="text-transform: lowercase;">ABS</b> rn, "cp3i4", <b style="text-transform: lowercase;">ABS</b> cp3i4, "cn3i4", <b style="text-transform: lowercase;">ABS</b> cn3i4, $l$ )) Output: Integer results:bt=1; bf=0; b2=1; b4=27; b8=342391; b16=-1059982867; ca=65; cb=66; sip=5; sin=5; ip=5; in=5; lip=5; lin=5; Real results:rp=4.2; rn=4.2; cp3i4=5.0; cn3i4=5.0;