D-U(1)

πŸ“¦ version 7.44.0, in nixpkgs unstable

🌸 D-U(1) β€” the d-u bestie manual page 🌸

πŸ’– NAME πŸ’–

okay so d-u β€” convert double-precision binary numbers to 16-bit unsigned shorts. that's the whole mission, bestie πŸ’…

✨ SYNOPSIS ✨

d-u [-n | scale] < doubles > unsigned_shorts

πŸ¦‹ DESCRIPTION πŸ¦‹

d-u reads a stream of machine-native double-precision (8-byte) binary floating point values from standard input, multiplies each value by a scale factor, and writes the result as 16-bit unsigned short integers to standard output. slay, simple.

Each scaled value gets clipped to the representable range: values above 65535 are written as 65535 and values below 0 are written as 0. the vibe check is strict β€” when any clipping occurs, a summary of how many high and low samples were clipped is reported on standard error.

The scale factor defaults to 1.0. A single optional argument controls scaling: either the -n flag or an explicit numeric scale value (the two are mutually exclusive). pick one, bestie.

Because the input is raw binary, d-u refuses to run when standard input is a terminal, and it also exits if the resulting scale is zero. The inverse conversion, from unsigned shorts back to binary doubles, is performed by u-d(1).

deprecation era: this command is deprecated and is scheduled for removal; it prints a deprecation warning on startup. not me showing up to the function with an expiration date 😭

πŸŽ€ OPTIONS πŸŽ€

  • -n β€” Normalize the data by using a scale factor of 65536.0, mapping input doubles in the range 0.0 to 1.0 across the full 0 to 65535 output range.
  • scale β€” Multiply every input value by this floating point factor before conversion. A scale of zero is rejected.

πŸ”₯ EXAMPLES πŸ”₯

Example 1. Quantize a normalized signal

d-u -n < signal.d > signal.u

Reads doubles in the range 0.0 to 1.0 from signal.d and writes 16-bit unsigned shorts spanning the full 0 to 65535 range, suitable as input to u-d(1) or other unsigned-short tools. ate, honestly.

Example 2. Apply an explicit gain and round-trip the data

d-u 1000 < values.d | u-d > scaled.d

Scales each double in values.d by 1000 before quantizing to unsigned shorts, then converts the result back to doubles with u-d(1), demonstrating the lossy quantization introduced by the conversion. lossy but make it fashion πŸ’…

🌈 SEE ALSO 🌈

brlcad(1), u-d(1), d-a(1), dconv(1), dmod(1)

πŸ‘‘ AUTHOR πŸ‘‘

BRL-CAD Team

This software is Copyright (c) 1989-2026 by the United States Government as represented by U.S. Army Research Laboratory.

πŸ› BUG REPORTS πŸ›

Reports of bugs or problems should be submitted via electronic mail to devs@brlcad.org


source/version: BRL-CAD; page tag: D-U(1); date: the footer doesn't print one, so I'm not inventing it, bestie β€” mwah πŸ’…πŸŽ€

πŸ“¦ where this page comes from