EconPapers    
Economics at your fingertips  
 

ROUND_EXACT: Stata module to perform exact decimal rounding using integer transformation to bypass floating-point noise

Anne Fengyan Shi ()
Additional contact information
Anne Fengyan Shi: Pew Research Center

Statistical Software Components from Boston College Department of Economics

Abstract: round_exact addresses the common issue of floating-point precision errors in Stata's built-in round(x, unit) function. Standard rounding often leaves "noise" in binary representation (e.g., round(0.3, 0.1) resulting in 0.30000000000000004), which causes logical assertions to fail. This command implements the formula: round(val * 10**d) / 10**d. By transforming the value into an integer before rounding, it avoids the precision errors introduced by fractional units.

Language: Stata
Requires: Stata version 14
Keywords: data management; rounding (search for similar items in EconPapers)
Date: 2026-04-06
Note: This module should be installed from within Stata by typing "ssc install round_exact". The module is made available under terms of the MIT license (https://opensource.org/licenses/MIT).
References: Add references at CitEc
Citations:

Downloads: (external link)
http://fmwww.bc.edu/repec/bocode/r/round_exact.ado program code (text/plain)
http://fmwww.bc.edu/repec/bocode/r/round_exact.sthlp help file (text/plain)

Related works:
This item may be available elsewhere in EconPapers: Search for items with the same title.

Export reference: BibTeX RIS (EndNote, ProCite, RefMan) HTML/Text

Persistent link: https://EconPapers.repec.org/RePEc:boc:bocode:s459663

Ordering information: This software item can be ordered from
http://repec.org/docs/ssc.php

Access Statistics for this software item

More software in Statistical Software Components from Boston College Department of Economics Boston College, 140 Commonwealth Avenue, Chestnut Hill MA 02467 USA. Contact information at EDIRC.
Bibliographic data for series maintained by Christopher F Baum ().

 
Page updated 2026-04-09
Handle: RePEc:boc:bocode:s459663