Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mohamedkhallouq
GitHub Repository: mohamedkhallouq/content
Path: blob/main/files/en-us/webassembly/reference/numeric/negate/index.md
6519 views
---
title: Negate slug: WebAssembly/Reference/Numeric/Negate
---

{{WebAssemblySidebar}}

The neg instructions, short for negate, are used to negate a number. That is, turn a positive number into a negative number and a negative number into a positive number.

{{EmbedInteractiveExample("pages/wat/neg.html", "tabbed-standard")}}

Syntax

;; load a number onto the stack f32.const 2.7 ;; round down f32.neg ;; the top item on the stack will now be 2
InstructionBinary opcode
f32.neg0x8c
f64.neg0x9a