Knowledge (XXG)

Unary operation

Source 📝

25: 1529: 402: 648:, can be seen as unary operations. This is because it is possible to provide only one term as input for these functions and retrieve a result. By contrast, binary operations, such as 176: 304: 542: 501: 646: 626: 606: 432: 452: 208: 1408: 919: 900: 825: 806: 108: 1554: 42: 89: 46: 61: 938: 68: 1549: 1533: 1428: 35: 1559: 1277: 75: 893: 1498: 1473: 1292: 585: 130: 57: 1446: 1297: 142: 660:
Below is a table summarizing common unary operators along with their symbols, description, and examples:
1212: 1414: 149: 397:{\displaystyle |n|={\begin{cases}n,&{\mbox{if }}n\geq 0\\-n,&{\mbox{if }}n<0\end{cases}}} 329: 1216: 980: 862: 1393: 1367: 1282: 1050: 281: 185: 509: 468: 82: 1272: 232: 138: 631: 611: 591: 1021: 284:
extending the square root sign over the argument can indicate the extent of the argument.
220: 407: 569: 565: 437: 298: 193: 1543: 1343: 1318: 462:
This is used to find the negative value of a single number. Here are some examples:
1054: 581: 950: 752: 277: 264: 122: 24: 1146: 1046: 799: 561: 268: 236: 1528: 992: 874: 649: 772: 134: 1004: 228: 1287: 276:). Other notations exist as well, for example, in the case of the 247: 224: 301:
of a number is a unary operation. This function is defined as
18: 390: 896:
family of languages, the following operators are unary:
372: 341: 634: 614: 594: 512: 471: 440: 410: 307: 196: 152: 556:, the product of the integers less than or equal to 652:, require two different terms to compute a result. 49:. Unsourced material may be challenged and removed. 640: 620: 600: 536: 495: 446: 426: 396: 202: 170: 766:flag = true; result = !flag; // result is false 762:Negates the truth value of a Boolean expression 782:Bitwise negation, flips the bits of an integer 572:is an unary operation extension of factorial. 137:, i.e. a single input. This is in contrast to 8: 1429:"Unary Operators - C Tutorials - Sanfoundry" 1057:), e.g., the following operators are unary: 141:, which use two operands. An example is any 16:Mathematical operation with only one operand 1447:"Shell Arithmetic (Bash Reference Manual)" 1413:. Version 6.0. p. 109. Archived from 633: 613: 593: 511: 470: 439: 419: 411: 409: 371: 340: 324: 316: 308: 306: 195: 151: 109:Learn how and when to remove this message 1472:Miran, Mohammad Shah (26 October 2023). 662: 1309: 786:num = 5; result = ~num; // result is -6 706:Decreases the value of a variable by 1 688:Increases the value of a variable by 1 1149:, the following operators are unary: 7: 47:adding citations to reliable sources 656:Examples from programming languages 14: 1527: 1407:"5. Expressions and Operators". 1368:"Unary Operators in Programming" 171:{\displaystyle f:A\rightarrow A} 23: 34:needs additional citations for 525: 516: 481: 475: 420: 412: 317: 309: 162: 1: 1505:. Microsoft. 3 September 2021 802:, these operators are unary: 245:), functional notation (e.g. 560:is a unary operation called 1576: 1499:"Expressions - PowerShell" 742:Indicates a negative value 728:a = -5; b = +a; // b is -5 724:Indicates a positive value 710:y = 10; --y; // y is now 9 1474:"Unary Operators in Bash" 1278:Iterated binary operation 746:c = 4; d = -c; // d is -4 692:x = 2; ++x; // x is now 3 552:For any positive integer 434:is the absolute value of 1410:C/C++ Language Reference 1077:Pre and Post-Decrement: 1061:Pre and Post-Increment: 212:is a unary operation on 1555:Operators (programming) 1293:Operation (mathematics) 586:trigonometric functions 537:{\displaystyle -(-3)=3} 496:{\displaystyle -(3)=-3} 1453:. GNU Operating System 1298:Operator (programming) 642: 622: 602: 538: 497: 448: 428: 398: 204: 172: 1348:mathworld.wolfram.com 1323:mathworld.wolfram.com 1228:Invoke in new scope: 888:C family of languages 643: 641:{\displaystyle \tan } 623: 621:{\displaystyle \cos } 603: 601:{\displaystyle \sin } 539: 498: 449: 429: 399: 219:Common notations are 205: 173: 1536:at Wikimedia Commons 1129:Complex expansion: 632: 612: 592: 564:. In the context of 510: 469: 438: 408: 305: 194: 150: 43:improve this article 1503:learn.microsoft.com 1342:Weisstein, Eric W. 1317:Weisstein, Eric W. 1120:Simple expansion: 427:{\displaystyle |n|} 1550:Elementary algebra 1433:www.sanfoundry.com 1344:"Binary Operation" 1203:Logical negation: 1111:Logical negation: 638: 618: 598: 534: 493: 444: 424: 394: 389: 376: 345: 200: 168: 1532:Media related to 1394:"Unary Operators" 1319:"Unary Operation" 1283:Ternary operation 1041:Unix shell (Bash) 791: 790: 447:{\displaystyle n} 375: 344: 203:{\displaystyle f} 139:binary operations 119: 118: 111: 93: 58:"Unary operation" 1567: 1560:Unary operations 1534:Unary operations 1531: 1515: 1514: 1512: 1510: 1495: 1489: 1488: 1486: 1484: 1469: 1463: 1462: 1460: 1458: 1443: 1437: 1436: 1425: 1419: 1418: 1404: 1398: 1397: 1390: 1384: 1383: 1381: 1379: 1364: 1358: 1357: 1355: 1354: 1339: 1333: 1332: 1330: 1329: 1314: 1273:Binary operation 1262: 1261: 1253: 1252: 1244: 1242: 1234: 1233: 1225: 1224: 1209: 1208: 1200: 1199: 1191: 1190: 1182: 1180: 1175: 1174: 1166: 1164: 1159: 1158: 1136: 1134: 1126: 1125: 1117: 1116: 1108: 1107: 1099: 1098: 1090: 1088: 1083: 1082: 1074: 1072: 1067: 1066: 1036: 1034: 1018: 1016: 1012: 1001: 1000: 993:Logical negation 989: 988: 981:Ones' complement 977: 976: 968: 967: 959: 958: 947: 946: 935: 933: 928: 927: 916: 914: 909: 908: 883: 882: 875:Logical negation 871: 870: 863:Ones' complement 859: 858: 850: 849: 841: 839: 834: 833: 822: 820: 815: 814: 787: 779: 767: 759: 747: 739: 729: 721: 711: 703: 693: 685: 663: 647: 645: 644: 639: 627: 625: 624: 619: 607: 605: 604: 599: 543: 541: 540: 535: 502: 500: 499: 494: 453: 451: 450: 445: 433: 431: 430: 425: 423: 415: 403: 401: 400: 395: 393: 392: 377: 373: 346: 342: 320: 312: 275: 262: 254: 244: 233:postfix notation 215: 211: 209: 207: 206: 201: 183: 179: 177: 175: 174: 169: 114: 107: 103: 100: 94: 92: 51: 27: 19: 1575: 1574: 1570: 1569: 1568: 1566: 1565: 1564: 1540: 1539: 1524: 1519: 1518: 1508: 1506: 1497: 1496: 1492: 1482: 1480: 1471: 1470: 1466: 1456: 1454: 1445: 1444: 1440: 1427: 1426: 1422: 1406: 1405: 1401: 1392: 1391: 1387: 1377: 1375: 1374:. 20 March 2024 1366: 1365: 1361: 1352: 1350: 1341: 1340: 1336: 1327: 1325: 1316: 1315: 1311: 1306: 1269: 1259: 1257: 1250: 1248: 1241:cast-expression 1240: 1238: 1231: 1229: 1222: 1220: 1206: 1204: 1197: 1195: 1188: 1186: 1178: 1177: 1172: 1170: 1162: 1161: 1156: 1154: 1143: 1132: 1130: 1123: 1121: 1114: 1112: 1105: 1103: 1096: 1094: 1086: 1085: 1080: 1078: 1070: 1069: 1064: 1062: 1043: 1033:cast-expression 1032: 1025: 1014: 1010: 1008: 998: 996: 986: 984: 974: 972: 965: 963: 956: 954: 944: 942: 931: 930: 925: 923: 912: 911: 906: 904: 890: 880: 878: 868: 866: 856: 854: 847: 845: 837: 836: 831: 829: 818: 817: 812: 810: 796: 785: 777: 765: 757: 745: 737: 727: 719: 709: 701: 691: 683: 658: 630: 629: 610: 609: 590: 589: 578: 566:complex numbers 550: 508: 507: 467: 466: 460: 436: 435: 406: 405: 388: 387: 369: 357: 356: 338: 325: 303: 302: 295: 290: 271: 256: 246: 239: 221:prefix notation 213: 192: 191: 189: 188:. The function 181: 148: 147: 145: 127:unary operation 115: 104: 98: 95: 52: 50: 40: 28: 17: 12: 11: 5: 1573: 1571: 1563: 1562: 1557: 1552: 1542: 1541: 1538: 1537: 1523: 1522:External links 1520: 1517: 1516: 1490: 1464: 1438: 1420: 1417:on 2012-10-16. 1399: 1385: 1359: 1334: 1308: 1307: 1305: 1302: 1301: 1300: 1295: 1290: 1285: 1280: 1275: 1268: 1265: 1264: 1263: 1254: 1245: 1235: 1226: 1210: 1201: 1192: 1183: 1167: 1142: 1139: 1138: 1137: 1127: 1118: 1109: 1100: 1091: 1075: 1042: 1039: 1038: 1037: 1019: 1002: 990: 978: 969: 960: 948: 936: 917: 889: 886: 885: 884: 872: 860: 851: 842: 823: 795: 792: 789: 788: 783: 780: 775: 769: 768: 763: 760: 755: 749: 748: 743: 740: 735: 731: 730: 725: 722: 717: 713: 712: 707: 704: 699: 695: 694: 689: 686: 681: 677: 676: 673: 670: 667: 657: 654: 637: 617: 597: 577: 574: 570:gamma function 549: 546: 545: 544: 533: 530: 527: 524: 521: 518: 515: 504: 503: 492: 489: 486: 483: 480: 477: 474: 459: 456: 443: 422: 418: 414: 391: 386: 383: 380: 370: 368: 365: 362: 359: 358: 355: 352: 349: 339: 337: 334: 331: 330: 328: 323: 319: 315: 311: 299:absolute value 297:Obtaining the 294: 293:Absolute value 291: 289: 286: 282:horizontal bar 199: 167: 164: 161: 158: 155: 133:with only one 117: 116: 31: 29: 22: 15: 13: 10: 9: 6: 4: 3: 2: 1572: 1561: 1558: 1556: 1553: 1551: 1548: 1547: 1545: 1535: 1530: 1526: 1525: 1521: 1504: 1500: 1494: 1491: 1479: 1475: 1468: 1465: 1452: 1448: 1442: 1439: 1434: 1430: 1424: 1421: 1416: 1412: 1411: 1403: 1400: 1395: 1389: 1386: 1373: 1372:GeeksforGeeks 1369: 1363: 1360: 1349: 1345: 1338: 1335: 1324: 1320: 1313: 1310: 1303: 1299: 1296: 1294: 1291: 1289: 1286: 1284: 1281: 1279: 1276: 1274: 1271: 1270: 1266: 1255: 1246: 1243: 1236: 1227: 1218: 1214: 1211: 1202: 1193: 1184: 1168: 1152: 1151: 1150: 1148: 1140: 1128: 1119: 1110: 1101: 1092: 1076: 1060: 1059: 1058: 1056: 1052: 1048: 1040: 1035: 1029: 1023: 1020: 1006: 1003: 994: 991: 982: 979: 970: 961: 952: 949: 940: 937: 921: 918: 902: 899: 898: 897: 895: 887: 876: 873: 864: 861: 852: 843: 827: 824: 808: 805: 804: 803: 801: 793: 784: 781: 776: 774: 771: 770: 764: 761: 756: 754: 751: 750: 744: 741: 736: 733: 732: 726: 723: 718: 715: 714: 708: 705: 700: 697: 696: 690: 687: 682: 679: 678: 674: 671: 668: 665: 664: 661: 655: 653: 651: 635: 615: 595: 587: 583: 575: 573: 571: 567: 563: 559: 555: 547: 531: 528: 522: 519: 513: 506: 505: 490: 487: 484: 478: 472: 465: 464: 463: 457: 455: 441: 416: 384: 381: 378: 366: 363: 360: 353: 350: 347: 335: 332: 326: 321: 313: 300: 292: 287: 285: 283: 279: 274: 270: 266: 260: 253: 249: 242: 238: 234: 230: 226: 222: 217: 197: 187: 165: 159: 156: 153: 144: 140: 136: 132: 128: 124: 113: 110: 102: 91: 88: 84: 81: 77: 74: 70: 67: 63: 60: –  59: 55: 54:Find sources: 48: 44: 38: 37: 32:This article 30: 26: 21: 20: 1507:. Retrieved 1502: 1493: 1481:. Retrieved 1477: 1467: 1455:. Retrieved 1450: 1441: 1432: 1423: 1415:the original 1409: 1402: 1388: 1376:. Retrieved 1371: 1362: 1351:. Retrieved 1347: 1337: 1326:. Retrieved 1322: 1312: 1239: 1144: 1055:Bourne Shell 1044: 1031: 1027: 891: 797: 659: 582:trigonometry 579: 576:Trigonometry 557: 553: 551: 461: 296: 272: 265:superscripts 258: 251: 240: 218: 126: 120: 105: 96: 86: 79: 72: 65: 53: 41:Please help 36:verification 33: 1478:LinuxSimply 1451:www.gnu.org 1215:in current 1169:Decrement: 1153:Increment: 951:Indirection 773:Bitwise NOT 753:Logical NOT 734:Unary Minus 672:Description 278:square root 123:mathematics 1544:Categories 1353:2020-07-29 1328:2020-07-29 1304:References 1194:Negative: 1185:Positive: 1147:PowerShell 1141:PowerShell 1102:Negative: 1093:Positive: 1047:Unix shell 971:Negative: 962:Positive: 853:Negative: 844:Positive: 800:JavaScript 794:JavaScript 716:Unary Plus 588:, such as 99:March 2010 69:newspapers 1028:type-name 1015:type-name 1013:, sizeof( 920:Decrement 901:Increment 826:Decrement 807:Increment 698:Decrement 680:Increment 562:factorial 548:Factorial 520:− 514:− 488:− 473:− 361:− 351:≥ 269:transpose 237:factorial 163:→ 131:operation 1509:23 April 1483:24 April 1457:24 April 1378:24 April 1267:See also 675:Example 666:Operator 650:addition 458:Negation 374:if  343:if  288:Examples 180:, where 143:function 1260:$ array 1256:Array: 1145:In the 1045:In the 1009:sizeof 939:Address 892:In the 263:), and 250:  210:⁠ 190:⁠ 178:⁠ 146:⁠ 135:operand 83:scholar 1247:Cast: 1237:Cast: 1213:Invoke 1005:Sizeof 669:Symbol 628:, and 584:, the 568:, the 404:where 267:(e.g. 235:(e.g. 223:(e.g. 129:is an 85:  78:  71:  64:  56:  1288:Arity 1230:& 1217:scope 943:& 184:is a 90:JSTOR 76:books 1511:2024 1485:2024 1459:2024 1380:2024 1131:$ {# 1051:Bash 1022:Cast 382:< 280:, a 257:sin( 125:, a 62:news 1251:$ x 1232:$ x 1223:$ x 1207:$ x 1198:$ x 1189:$ x 1179:$ x 1173:$ x 1163:$ x 1157:$ x 1115:$ x 1106:$ x 1097:$ x 1087:$ x 1081:$ x 1071:$ x 1065:$ x 798:In 636:tan 616:cos 596:sin 580:In 255:or 248:sin 231:), 186:set 121:In 45:by 1546:: 1501:. 1476:. 1449:. 1431:. 1370:. 1346:. 1321:. 1219:: 1181:-- 1176:, 1171:-- 1165:++ 1160:, 1155:++ 1122:$ 1089:-- 1084:, 1079:-- 1073:++ 1068:, 1063:++ 1030:) 1024:: 1007:: 995:: 983:: 953:: 941:: 934:-- 929:, 924:-- 922:: 915:++ 910:, 905:++ 903:: 877:: 865:: 840:-- 835:, 830:-- 828:: 821:++ 816:, 811:++ 809:: 702:−- 684:++ 608:, 454:. 227:, 216:. 1513:. 1487:. 1461:. 1435:. 1396:. 1382:. 1356:. 1331:. 1258:, 1249:+ 1221:. 1205:! 1196:- 1187:+ 1135:} 1133:x 1124:x 1113:! 1104:- 1095:+ 1053:/ 1049:( 1026:( 1017:) 1011:x 999:x 997:! 987:x 985:~ 975:x 973:- 966:x 964:+ 957:x 955:* 945:x 932:x 926:x 913:x 907:x 894:C 881:x 879:! 869:x 867:~ 857:x 855:- 848:x 846:+ 838:x 832:x 819:x 813:x 778:~ 758:! 738:- 720:+ 558:n 554:n 532:3 529:= 526:) 523:3 517:( 491:3 485:= 482:) 479:3 476:( 442:n 421:| 417:n 413:| 385:0 379:n 367:, 364:n 354:0 348:n 336:, 333:n 327:{ 322:= 318:| 314:n 310:| 273:A 261:) 259:x 252:x 243:! 241:n 229:− 225:¬ 214:A 198:f 182:A 166:A 160:A 157:: 154:f 112:) 106:( 101:) 97:( 87:· 80:· 73:· 66:· 39:.

Index


verification
improve this article
adding citations to reliable sources
"Unary operation"
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
mathematics
operation
operand
binary operations
function
set
prefix notation
¬

postfix notation
factorial
sin
superscripts
transpose
square root
horizontal bar
absolute value
factorial
complex numbers

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.