Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::labs

 

std::labs is a C-style function to obtain the absolute value of a long.

 

std::abs is a function to obtain the absolute value of most numeric data types.

 

 

 

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: CppLabs.pro

 

QT       -= core
QT       -= gui
TARGET = CppLabs
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app
SOURCES += main.cpp

 

 

 

 

 

main.cpp

 

#include <cassert>
#include <cstdlib>

int main()
{
  const long i = -23;
  const long j =  23;
  assert(std::labs(i) == j);
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml