HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to HaskellVariables (let)Data TypesOperatorsStringsListsConditions (if / then / else)Iteration (map / sum)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Value & Type
🔢 Numbers & Math
Math operatorssqrt / abs / ^
✍️ String
📚 List
🔀 Condition
🧩 Function
Haskell›REFERENCE›Numbers & Math
🔢

Numbers & Math

Operators and mathematical functions.

CommandDescription
Math operatorsFour basic operations, integer division, and remainder.
sqrt / abs / ^Square root, absolute value, exponent.

Math operators

Try it yourself →

Four basic operations, integer division, and remainder.

Syntax

+  -  *  div  mod  /

Description

Integer division is with div, and remainder with mod. / is only used with floating-point (Double) numbers (7.0/2.0).

Example

main = do
  print (7 + 3)
  print (div 7 2)
  print (mod 7 2)
  print (7.0 / 2.0)

Expected output

10
3
1
3.5

When to use?

Calculations, even/odd check (mod x 2 or even).

Common mistakes

  • ⚠️ Do not use / with Int; perform integer operations with div/mod.

sqrt / abs / ^

Try it yourself →

Square root, absolute value, exponent.

Syntax

sqrt x   abs x   x ^ y

Description

sqrt gives the square root (returns a Double), abs the absolute value, and ^ the exponent (integer exponent). Can be used directly.

Example

main = do
  print (sqrt 81)
  print (abs (-5))
  print (2 ^ 10)

Expected output

9.0
5
1024

When to use?

Geometry, statistics, exponential calculations.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code