bugGNU Octave - Bugs: bug #44709, sprintf('%03g', 10) returns only 2...

 
 

bug #44709: sprintf('%03g', 10) returns only 2 char

Submitter:  None
Submitted:  Fri 03 Apr 2015 03:08:31 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Wont Fix Assigned to:  None
Originator Name:  Xiangrui Li Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.8.2
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 07 Apr 2015 11:52:32 AM UTC, comment #10: 
John Donoghue <lostbard>
Group Member
Mon 06 Apr 2015 02:10:51 PM UTC, comment #9: 

I believe I found the issue in mingw-w64 and have submitted a patch to mingw-w64. [1]

In the mean time, I will probally add a patch to mxe-octave  when compiling mingw-w64.

[1] http://sourceforge.net/p/mingw-w64/mailman/message/33732797/

John Donoghue <lostbard>
Group Member
Sat 04 Apr 2015 06:53:08 PM UTC, comment #8: 

Someone can report the bug upstream to gnulib.  For Octave, marking this as 'Won't Fix" and closing.

Rik <rik5>
Group administrator
Sat 04 Apr 2015 06:36:02 PM UTC, comment #7: 

I think we should just report the problem to the gnulib maintainers and let them decide whether they want to try to provide a workaround for it.  It makes sense for the fix to go in gnulib since that's the whole purpose of gnulib.  But they may not be particularly interested in mingw-w64.

John W. Eaton <jwe>
Group administrator
Sat 04 Apr 2015 03:55:54 PM UTC, comment #6: 

Do we need to do anything at all?  Or can we mark this as an upstream bug?

Rik <rik5>
Group administrator
Fri 03 Apr 2015 11:39:44 PM UTC, comment #5: 

If we decide to try to work around this problem, then it seems like something that should be done in gnulib, not directly in Octave.

John W. Eaton <jwe>
Group administrator
Fri 03 Apr 2015 03:00:19 PM UTC, comment #4: 

An report issue with mingw-w64 printf:

http://sourceforge.net/p/mingw-w64/bugs/362/


John Donoghue <lostbard>
Group Member
Fri 03 Apr 2015 02:07:53 PM UTC, comment #3: 

Creating a small c++ program:

#define _GNU_SOURCE
//#undef _GNU_SOURCE
#include <stdio.h>

int main()
{
  double d = 40;
  printf("d=%03g\n", d);
  return 0;
}


With define _GNU_SOURCE, in Linux prints 3 characters, in windows prints 2.
With the undef,  prints 3 characters for both Linux and windows.

John Donoghue <lostbard>
Group Member
Fri 03 Apr 2015 12:15:52 PM UTC, comment #2: 

I see the same on my windows build - cant remember what hg id it was, but am building a new one now to verify it is still an issue.


>> sprintf('%03g', 40)
ans = 40
>> sprintf('%04g', 40)
ans = 0040
>> sprintf('%04g', 400)
ans = 400
>>


John Donoghue <lostbard>
Group Member
Fri 03 Apr 2015 09:40:00 AM UTC, comment #1: 

works fine with rc2

hg id
cf9b94a89620 tip



>> sprintf('%03g', 20)

ans = 020

>> sprintf('%03g', 30)

ans = 030

Doug Stewart <dastew>
Fri 03 Apr 2015 03:08:31 AM UTC, original submission:  

sprintf('%03g', 1)
ans = 001

sprintf('%03g', 20) % only 2-char for 10, 20, 30 etc
ans = 20

sprintf('%03g', 21)
ans = 021

The same problem exists for printf and fprintf.

sprintf('%03.0f', 20) % work fine
ans = 020


I tested this under Windows only, so don't know the behavior under Linux.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by dastew (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-04-04 rik5 StatusConfirmed Wont Fix
        Open/ClosedOpen Closed
    2015-04-03 lostbard StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code