Knowledge (XXG)

Unary operation

Source 📝

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

Index

Unary operator

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

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