help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: %u format is broken in *printf functions in octave-4.2.2


From: Kai Torben Ohlhus
Subject: Re: %u format is broken in *printf functions in octave-4.2.2
Date: Tue, 16 Apr 2019 23:06:05 +0900

On Tue, Apr 16, 2019 at 10:31 PM Doug Stewart <address@hidden> wrote:
On Tue, Apr 16, 2019 at 4:58 AM Sergei Steshenko <address@hidden> wrote:
Hello All,


after for several years using my self-built octave-3.6.4 I finally
switched to octave-4.4.2 distributed with Ubuntu-18.04.

And I've noticed that *printf functions work wrongly with %u format:


"
octave:3> printf("%u\n", 1234567.890123456)
1.23457e+06
octave:4> sprintf("%u\n", 1234567.890123456)
ans = 1.23457e+06

octave:5> version
ans = 4.2.2

".


%u format is supposed to output without decimal period and exponent. In
this particular case I expect output like this (the same machine and OS) :
"
address@hidden:~$ perl -e 'printf("%07u\n", 1234567.890123456)'
1234567
".

Am I missing something or it's a bug ? And if it's a bug, will using
'floor', like here:


"
octave:8> sprintf("%u\n", floor(1234567.890123456))
ans = 1234567

"


be a reliable workaround ?

Thanks,
   Sergei.



This seems to be a bug that is still there in octave 5.1.1

--
DASCertificate for 206392



It's not a bug, it's a Matlab feature ;-)  Introduced with Octave 4.0.0, for details and a workaround see https://savannah.gnu.org/bugs/?45639 .

HTH,
Kai 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]