LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-23-2011, 04:56 PM   #1
skiabox
Member
 
Registered: Dec 2006
Posts: 44

Rep: Reputation: 0
I want to use dot instead of comma


If I give the command: printf (%f) 25.35
I get the following error :

-bash: printf: 12.34: invalid number

If I replace 25.35 with 25,35 there is nor error.
How can I use dot instead of comma in my numbers?
Thank you.
 
Old 10-23-2011, 05:00 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Firstly, put the format string in single quotes. The shell will try to run '%f' in a subshell instead of taking it as the format string. If a comma is still expected, look at your locale settings. Some locales may use a comma instead of a decimal point.

Code:
printf '(%f)\n' 25.35
(25.350000)

Last edited by jschiwal; 10-23-2011 at 05:02 PM.
 
Old 10-23-2011, 05:16 PM   #3
skiabox
Member
 
Registered: Dec 2006
Posts: 44

Original Poster
Rep: Reputation: 0
I meant "%f".I have changed the settings in my macbook pro and even did a restart but the terminal insists on using the comma for decimal separator.
 
Old 10-23-2011, 05:24 PM   #4
SecretCode
Member
 
Registered: Apr 2011
Location: UK
Distribution: Kubuntu 11.10
Posts: 562

Rep: Reputation: 102Reputation: 102
What is your locale?
Code:
locale
 
Old 10-23-2011, 05:27 PM   #5
skiabox
Member
 
Registered: Dec 2006
Posts: 44

Original Poster
Rep: Reputation: 0
Code:
LANG="el_GR.UTF-8"
LC_COLLATE="el_GR.UTF-8"
LC_CTYPE="el_GR.UTF-8"
LC_MESSAGES="el_GR.UTF-8"
LC_MONETARY="el_GR.UTF-8"
LC_NUMERIC="el_GR.UTF-8"
LC_TIME="el_GR.UTF-8"
LC_ALL=
 
Old 10-23-2011, 06:26 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Ok; so that's a Greek locale http://docs.moodle.org/dev/Table_of_locales and according to this https://secure.wikimedia.org/wikiped...Digit_grouping Greece uses the comma as the 'decimal radix/point' https://secure.wikimedia.org/wikiped...Digit_grouping
 
  


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
How to delete Comma in a comma separated file with double quotes as quote character pklcnu Linux - Newbie 2 03-24-2009 06:50 PM
comma operator in C cleopard Programming 16 04-25-2008 10:57 AM
dot space dot binary_0011 Linux - Newbie 5 09-14-2006 08:43 AM
useradd not accepting dot so i am not able to use dot in mail id hanu_raob Linux - General 5 05-13-2004 08:04 AM
decimal comma notation conversion to dot? heaslein69 Linux - Software 2 01-25-2002 05:05 AM


All times are GMT -5. The time now is 03:02 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration