Skip to main content

IAR Embedded Workbench for RISC-V 3.40

Math functions

In this section:

Some C/C++ standard library math functions are available in different versions:

  • The default versions

  • Smaller versions (but less accurate)

  • More accurate versions (but larger).

Smaller versions

The functions cos, exp, log, log2, log10, pow, sin, and tan exist in additional, smaller versions in the library. They are about 20% smaller and about 20% faster than the default versions. The functions handle INF and NaN values. The drawbacks are that they almost always lose some precision and they do not have the same input range as the default versions.

The names of the functions are constructed like:

__iar_ xxx _small<f|l>

where f is used for float variants, l is used for long double variants, and no suffix is used for double variants.

EWICO.png To specify which set of math functions to use:
  1. Choose Project>Options>General Options>Library Options 1>Math functions and choose which set to use.

  2. Link your application and the chosen set will be used.

CLICO.png To specify smaller math functions on the command line:
  1. Specify the command line option ‑‑small_math to the linker.

  2. Link your application and the complete set will be used.

More accurate versions

The functions cos, pow, sin, and tan exist in versions in the library that are more exact and can handle larger argument ranges. The drawback is that they are larger and slower than the default versions.

The names of the functions are constructed like:

__iar_ xxx _accurate<f|l>

where f is used for float variants, l is used for long double variants, and no suffix is used for double variants.

CLICO.png To specify more accurate math functions on the command line:
  1. Specify the command line option ‑‑accurate_math to the linker.

  2. Link your application and the complete set will be used.