HP3000-L Archives

February 2006, Week 1

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
john pitman <[log in to unmask]>
Reply To:
john pitman <[log in to unmask]>
Date:
Mon, 6 Feb 2006 11:19:12 +1100
Content-Type:
text/plain
Parts/Attachments:
text/plain (80 lines)
We may need to convert some C code to work in a euro number presentation
environment, and I have looked up setlocale() etc, and the decimal place
works fine, but I cant get any sense out of thousands separator. We don't
actually use it ourselves (takes up space in screens and reports), but why
doesn't it work?

All the docos I have found on HP state to do

Setlocale("LC_ALL","")     to force set up

And to use an apostrophe in the format, as in "%'8.2f" to tell printf to use
the separator and decimal point from locale(), but all I get instead of a
number  (12345.67)   is       '8.2f  .

 

Am I barking up the wrong tree here, or doing something wrong please?

 

Jp

 

This code

#include <locale.h>

#include <math.h>

 

/************************************************************/

main() {

 

 

int error,status[10];

double d1=12345.67;

struct lconv *lc;

lc = localeconv();

setlocale("LC_ALL","");

printf("%'8.2f\n",d1);

setlocale(LC_ALL,"portuguese");

printf("%8.2f\n",d1);

setlocale(LC_ALL,"english");

printf("%8.2f\n",d1);

 

Gives this result:-

:tlocale.c

'8.2f

12345,67

12345.67

 

 


* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2