LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 03: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, 04:00 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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 04:02 PM.
 
Old 10-23-2011, 04: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, 04: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, 04: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, 05:26 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,369

Rep: Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753
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



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 05:50 PM
comma operator in C cleopard Programming 16 04-25-2008 09:57 AM
dot space dot binary_0011 Linux - Newbie 5 09-14-2006 07: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 07:04 AM
decimal comma notation conversion to dot? heaslein69 Linux - Software 2 01-25-2002 04:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:19 AM.

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
Open Source Consulting | Domain Registration