fix_negative_zero: Fix negative zero in formatted strings

View source: R/fit_utils.R

fix_negative_zeroR Documentation

Fix negative zero in formatted strings

Description

Corrects floating-point rounding artifacts that produce "-0.00" or similar negative zero strings. Works on character vectors, replacing patterns like "-0.00", "-0.000", etc. with their positive equivalents, even when embedded within larger strings (e.g., "(-0.00, 1.23)" becomes "(0.00, 1.23)").

Usage

fix_negative_zero(x, marks = NULL)

Arguments

x

Character vector of formatted numbers.

marks

Optional list with big.mark and decimal.mark as returned by resolve_number_marks. When NULL, uses the default US period decimal.

Details

When marks is supplied, also replaces the period decimal mark with the locale-appropriate decimal mark.

Value

Character vector with negative zeros corrected.


summata documentation built on May 7, 2026, 5:07 p.m.