LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-12-2007, 01:16 PM   #1
slomek
LQ Newbie
 
Registered: Feb 2006
Distribution: Debian Etch
Posts: 8

Rep: Reputation: 1
[C] writing floating point to file- coma instead of dot


I write number to file like this:
Code:
fprintf(file,"%f",float_number);
And I get e.g. 2,5000 instead of 2.5000. This causes many problems in reading this file by other programs. How to fix this?
I have gcc 4.1.2 and Debian Etch with Polish locales.

Last edited by slomek; 04-12-2007 at 01:19 PM.
 
Old 04-12-2007, 01:52 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,011

Rep: Reputation: 110Reputation: 110
Switch to "C" locale sometime before this. Or complain to those other program's maintainers that they aren't respecting locale properly. The comma is the Right Thing to do in the Polish locale, so you really shouldn't need to change that.
 
Old 04-12-2007, 02:14 PM   #3
slomek
LQ Newbie
 
Registered: Feb 2006
Distribution: Debian Etch
Posts: 8

Original Poster
Rep: Reputation: 1
Quote:
Switch to "C" locale sometime before this.
What do you mean? Or rather: how am I supposed to do this?
 
Old 04-12-2007, 02:43 PM   #4
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,482

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Quote:
Originally Posted by slomek
What do you mean? Or rather: how am I supposed to do this?
Here is one way:
Code:
export LC_NUMERIC=C
 
Old 04-12-2007, 03:23 PM   #5
slomek
LQ Newbie
 
Registered: Feb 2006
Distribution: Debian Etch
Posts: 8

Original Poster
Rep: Reputation: 1
Thanks a lot!
That worked. I must have changed something with my locales. Now its OK.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
suggestions for using xslt to view base64-encoded floating point data in an xml file? zero79 Programming 0 01-10-2006 06:52 PM
Floating Point in kernel 2.4.28 lucs Slackware 1 10-19-2005 08:33 AM
Floating point exception hemk76 Linux - Software 1 05-06-2005 11:49 PM
floating point multiplication irfanhab Programming 0 12-23-2004 10:13 PM
managing floating point vince_2x Linux - General 2 09-21-2004 09:05 PM


All times are GMT -5. The time now is 01:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration