Re: hexadecimal et printf

2002-09-06 Par sujet nicolas
Le mer, 04 sep 2002 11:37:21 Frédéric Bothamy a écrit :

[EMAIL PROTECTED]:~$ builtin printf %d\n 0xff
»255
[EMAIL PROTECTED]:~$ /usr/bin/printf %d\n 0xff
»255
[EMAIL PROTECTED]:~$ echo $SHELL
»/bin/bash

Chez moi, sur ma patate, seul /usr/bin/printf fonctionne en conversion 
hexadécimal vers décimal.

nicolas patrois, pts noir asocial
-- 
MÉDECINE DOUCE

M : Y a des cons, pour se soigner... ils se mettent des grains de riz sur 

les points d'acuponcture... alors que ça ne marche vraiment bien qu'avec 
du cassoulet.
-- Maurice et Patapon





hexadecimal et printf

2002-09-04 Par sujet kamel

At 09:29 04/09/2002 +0200, Romuald DELAVERGNE wrote:

Le 2002.09.03 17:06, kamel a écrit :

Une question bête, comment faites-vous le calcul ?


Un moyen simple et rapide de faire des conversions hexadécimale - 
décimale à partir d'un shell:


 * printf 0x%X\n nombreDecimal


là, ca marche :
aristote:~# printf 0x%X\n 255
0xFF



 * printf %d\n nombreHexadecimal (précéder le nombre par 0x : 0xff par ex.)


là, ca ne marche pas tres bien
aristote:~# printf %d\n 0xff
bash: printf: 0xff: illegal number



C'était the tip of the day :-)


merci




--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: hexadecimal et printf

2002-09-04 Par sujet Romuald DELAVERGNE

là, ca ne marche pas tres bien

Pourtant ça devrait


aristote:~# printf %d\n 0xff
bash: printf: 0xff: illegal number



0xff: tu as bien tappé un zéro et pas 'o' majuscule pour 0xff ?



Re: hexadecimal et printf

2002-09-04 Par sujet Arnaud Delobelle
On Wed, Sep 04, 2002 at 09:42:47AM +0200, kamel wrote:
 aristote:~# printf %d\n 0xff
 bash: printf: 0xff: illegal number
 
[EMAIL PROTECTED]:~$ printf %d\n 0xff
255

-- 
Arnaud Delobelle



Re: hexadecimal et printf

2002-09-04 Par sujet kamel

At 10:09 04/09/2002 +0200, Romuald DELAVERGNE wrote:

là, ca ne marche pas tres bien

Pourtant ça devrait


aristote:~# printf %d\n 0xff
bash: printf: 0xff: illegal number


0xff: tu as bien tappé un zéro et pas 'o' majuscule pour 0xff ?


oui, je suis surppris de ce comportement de ma machine.
j'utilise le chiffre 0 et la lettre minuscule x
et j'obtient
aristote:~#  printf %d\n 0xff
bash: printf: 0xff: illegal number
aristote:~#  printf %d\n 0xff
bash: printf: 0xff: illegal number

enfin, ce n'est pas grave mais je demande  quoi cela est du ?

merci, @+


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: hexadecimal et printf

2002-09-04 Par sujet Frédéric Bothamy
On Wed, Sep 04, 2002 at 10:37:33AM +0200, kamel wrote:
 At 10:09 04/09/2002 +0200, Romuald DELAVERGNE wrote:
 là, ca ne marche pas tres bien
 Pourtant ça devrait
 
 aristote:~# printf %d\n 0xff
 bash: printf: 0xff: illegal number
 
 0xff: tu as bien tappé un zéro et pas 'o' majuscule pour 0xff ?
 
 oui, je suis surppris de ce comportement de ma machine.
 j'utilise le chiffre 0 et la lettre minuscule x
 et j'obtient
 aristote:~#  printf %d\n 0xff
 bash: printf: 0xff: illegal number
 aristote:~#  printf %d\n 0xff
 bash: printf: 0xff: illegal number
 
 enfin, ce n'est pas grave mais je demande  quoi cela est du ?

Peut-être bien au fait que tu n'utilises pas le même printf que nous
si tu n'utilises pas le même shell (builtin contre commande
externe). Avec celui de bash 2.05a-1 et avec celui de shellutils
2.0.11-11, ça fonctionne :

[EMAIL PROTECTED]:~$ builtin printf %d\n 0xff
255
[EMAIL PROTECTED]:~$ /usr/bin/printf %d\n 0xff
255
[EMAIL PROTECTED]:~$ echo $SHELL
/bin/bash

J'ai trouvé cette explication dans le changelog Debian de shellutils
(auquel appartient /usr/bin/printf) et c'est également écrit dans la
page de manuel en anglais de printf.

Fred