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

{{WebAssemblySidebar}}

The abs instructions, short for absolute, are used to get the absolute value of a number. That is, it returns x if x is positive, and the negation of x if x is negative.

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

Syntax

;; load a number onto the stack f32.const -2 ;; absolute f32.abs ;; the top item on the stack will now be 2
InstructionBinary opcode
f32.abs0x8b
f64.abs0x99