Artifact 3960dead6218f6f6c52227a750888202ed0d6043ab387e11b871279262990e1e:
- File doc/markdown/Tcl/frexp.md — part of check-in [53d963650f] at 2026-10-05 21:52:35 on branch tip-700 — - file location re-organisation (part 2 of 2) - added manual pages from Tcl 9.1: divmod, frexp, lfilter, modf, remquo, timer; incl. final conversions - unified timer.n - moved 'package prefer' into the alphabetical order of the other subcommands (user: Torsten, size: 1091) [annotate] [blame] [check-ins using]
CommandName: frexp title: frexp ManualSection: n Version: 9.1 TclPart: Tcl TclDescription: Tcl Float Decomposition Links:
- expr(n)
- mathfunc(n)
- modf(n) Keywords:
- floating point Copyright:
- Copyright (c) 2025 Donal Fellows ---
Name
frexp - Split a floating-point number into fraction and exponent parts
Synopsis
::: {.synopsis} ::: [package]{.cmd} [require]{.sub} [tcl]{.lit} [9.1]{.lit} [frexp]{.cmd} [value]{.arg} :::
Description
The frexp command takes a floating-point number, value, and returns a list of two values. The first element of the result is the fractional part of value (signed, of magnitude between 0.5 and 1.0), and the second element of the result is the integer exponent from value. When value is infinite, the fraction is also infinite (of the same sign).
Example
The frexp command is paired with the ldexp function, like this:
set value 123.456
lassign [frexp $value] frac exp
set recovered [expr { ldexp($frac, $exp) }]
puts "$value -> $frac*2**$exp -> $recovered"
# 123.456 -> 0.9645*2**7 -> 123.456