Bash printf
floating number formatting (with %f
or %g
) is suddenly completely wrong, and changing all the time.
An example output:
$ export LC_ALL=C
$ printf '%gn' 1
1.20739e+3531
$ printf '%gn' 1
4.50784e-4778
$ printf '%gn' 1
1.20739e+3531
$ printf '%gn' 1
-2.71289e-809
$ printf '%gn' 1
1.3505e+3136
$ printf '%gn' 1
7.19546e+2880
$ printf '%fn' 1
0.000000
$ printf '%fn' 1
-19222373783767455764509969957314767706032565305205751517976389011586356910287283735873496366975075385910809025031233228909443235485943598697862160225065543796566324326303010027986380740507313362109478389280032720809755605977575591712977484833714421549464179548312816619669691695969675768618124142786377660052446990574866227828104911221712770547544994592495621702453486060768120985842267603349960735550433657827156688542311891238932963870595675569407105652838611000368894193915118759451716250477855842495787217908770520219596001805968923516834815448319714521179606192054239712352794281273655344703644255690153172028191401140768961585354430400117766273628103129509500449952562778071128862373050266582261154261590345666202936676378315868263637718127652344391988248019089245237502067305800855582602326233046151999935749805709388443164385685796904118233897433899895164143403147924128628840995216653448904704.000000
$ printf '%fn' 1
-1535939692251970798780814048195400843655654544941633379309930935432267368465724365567117453392273362651582982424721184431169329486749020702578930669204206705946793193732917405530938783202632819503328225917797530425669645856818642162664722510713747202433401571296943178862058175872487260754269792220244257605097737000140353828109440097622967061126831273879953063844519410176251996107980841451192710472925184.000000
$ printf '%fn' 1
-559936185544451048996856397218869061556420299014564433770484452018186365447891968084773838558135844864.000000
It is bash builtin that is being used, as I can see when typing command -v printf
.
alias printf
says “not found”. I have the binaries at /bin/printf
and /usr/bin/printf
that behave normally. Awk and Python equivalent commands behave normally.
I am on Debian testing, and I tried to apt upgrade
and reboot but the bug persists.
Bash version is GNU bash, version 5.2.32(1)-release (x86_64-pc-linux-gnu)
. I tried apt reinstall bash
without success. Yesterday for another reason I did a apt-get dist-upgrade
.
What have I done?! It’s wild.