GNU bug report logs - #11085
RFE: teach factor to read/write hexadecimal

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: coreutils; Severity: wishlist; Reported by: Adam Back <adam@HIDDEN>; Keywords: notabug; dated Sat, 24 Mar 2012 18:33:01 UTC; Maintainer for coreutils is bug-coreutils@HIDDEN.
Changed bug title to 'RFE: teach factor to read/write hexadecimal' from 'factor only supports decimal numbers, doh' Request was from Jim Meyering <jim@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Added tag(s) notabug. Request was from Jim Meyering <jim@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Severity set to 'wishlist' from 'normal' Request was from Jim Meyering <jim@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 11085 <at> debbugs.gnu.org:


Received: (at 11085) by debbugs.gnu.org; 27 Mar 2012 08:16:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 27 04:16:29 2012
Received: from localhost ([127.0.0.1]:40607 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1SCRZn-00047X-DH
	for submit <at> debbugs.gnu.org; Tue, 27 Mar 2012 04:16:29 -0400
Received: from mx.meyering.net ([88.168.87.75]:60678)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <jim@HIDDEN>)
	id 1SCRZW-000473-2V; Tue, 27 Mar 2012 04:16:22 -0400
Received: from rho.meyering.net (localhost.localdomain [127.0.0.1])
	by rho.meyering.net (Acme Bit-Twister) with ESMTP id 23D3E60094;
	Tue, 27 Mar 2012 09:44:48 +0200 (CEST)
From: Jim Meyering <jim@HIDDEN>
To: Adam Back <adam@HIDDEN>
Subject: Re: bug#11085: factor only supports decimal numbers, doh
In-Reply-To: <20120325132301.GA26476@HIDDEN> (Adam Back's
	message of "Sun, 25 Mar 2012 15:23:01 +0200")
References: <20120324150711.GA24123@HIDDEN>
	<87aa35yv28.fsf@HIDDEN>
	<20120325132301.GA26476@HIDDEN>
Date: Tue, 27 Mar 2012 09:44:48 +0200
Message-ID: <8762dqwkr3.fsf@HIDDEN>
Lines: 61
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -1.9 (-)
X-Debbugs-Envelope-To: 11085
Cc: 11085 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -1.9 (-)

severity 11085 wishlist
tags 11085 notabug
retitle 11085 RFE: teach factor to read/write hexadecimal
thanks

Adam Back wrote:
> Thanks for replying.  I am aware of bc, dc etc.  And in fact that was what I
> did to work around (used bc), but it seems like unnecessary feature removal
> when the underlying crypto library the tool is calling to actually do the
> work is more natively working with hex (binary).
>
> Sorry about getting off on the wrong foot with the "stupid" word mixed into
> my thought.
>
> I have been using unix exclusively since 1989, and yes I am a fan of the
> unix philosophy.  I would qualify "it is possible to use other tools to work
> around the lack of this feature" to more the tools are scalable,
> conveniently pluggable etc.  And convenient pluggability applies IMO.
>
> Eg lets say od can output in different formats (-tx1 I use commonly if I
> need convert a file into something suitable to chain with some other crypto
> command line tool) ...  you "could" no doubt work around that with awk, perl
> or maybe even bc if you were creative, but it just makes things less
> convenient to chain if the default or only output is not directly
> compatibile with the main consuming next in the chain tools natural, default
> or only input...

You can define a shell function like this to handle the input conversion:

f2(){ factor $( { echo ibase=16\;;echo "$*"|tr a-f A-F|tr -s ' ' \;; } |bc); }

and use it like this:

    $ f2 FF FFF
    255: 3 5 17
    4095: 3 3 5 7 13

Considering that to get the same effect internally (in factor.c),
I would have to change two separate code paths (with/without GMP),
and -- perhaps more importantly -- that yours is the first request
for this feature, your using the simple wrapper is preferable.

And that is considering only the input conversion.
I'm sure you can find or write a tool that parses an arbitrary
stream of integers and converts them from decimal to hexadecimal.
So far, it does not seem justified to add an option for that.

However, if someone is interested enough to write patches, you might
be able to convince us that a hexadecimal input should be accepted
and should cause factors to be printed in hexadecimal.  e.g.,

    $ factor 0xFF 0xFFF
    0xFF: 3 5 11
    0xFFF: 3 3 5 7 C

Then there's no need for a new option.

But realize that this is no trivial task and would require an FSF
copyright assignment.
As usual, the change set would also have to add tests (be sure to
exercise both code paths) and update documentation and NEWS.




Information forwarded to bug-coreutils@HIDDEN:
bug#11085; Package coreutils. Full text available.

Message received at 11085 <at> debbugs.gnu.org:


Received: (at 11085) by debbugs.gnu.org; 25 Mar 2012 13:51:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 25 09:51:57 2012
Received: from localhost ([127.0.0.1]:37693 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1SBnrQ-0001UI-9d
	for submit <at> debbugs.gnu.org; Sun, 25 Mar 2012 09:51:57 -0400
Received: from mail-wg0-f42.google.com ([74.125.82.42]:45606)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <adam.back@HIDDEN>) id 1SBnr9-0001Tx-PO
	for 11085 <at> debbugs.gnu.org; Sun, 25 Mar 2012 09:51:54 -0400
Received: by wgbds11 with SMTP id ds11so2010209wgb.3
	for <11085 <at> debbugs.gnu.org>; Sun, 25 Mar 2012 06:20:34 -0700 (PDT)
Received: by 10.180.104.230 with SMTP id gh6mr10946228wib.22.1332681634795;
	Sun, 25 Mar 2012 06:20:34 -0700 (PDT)
Received: from netbook (c107-41.i07-27.onvol.net. [92.251.107.41])
	by mx.google.com with ESMTPS id w10sm52496255wiy.3.2012.03.25.06.20.30
	(version=TLSv1/SSLv3 cipher=OTHER);
	Sun, 25 Mar 2012 06:20:31 -0700 (PDT)
Received: by netbook (Postfix, from userid 204881528)
	id 6E32E34029D; Sun, 25 Mar 2012 15:23:03 +0200 (CEST)
Received: by eee (hashcash-sendmail, from uid 204881528);
	Sun, 25 Mar 2012 15:23:02 +0200
Date: Sun, 25 Mar 2012 15:23:01 +0200
From: Adam Back <adam@HIDDEN>
To: Jim Meyering <jim@HIDDEN>
Subject: Re: bug#11085: factor only supports decimal numbers, doh
Message-ID: <20120325132301.GA26476@HIDDEN>
References: <20120324150711.GA24123@HIDDEN>
	<87aa35yv28.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Disposition: inline
In-Reply-To: <87aa35yv28.fsf@HIDDEN>
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Hashcash: 1:20:120325:jim@HIDDEN::kmxjP3SJJNlzaEfW:03Wvw
X-Hashcash: 1:20:120325:11085 <at> debbugs.gnu.org::EYqRoxtz5f7yMglh:0000000000000000
	0000000000000000000000005yYq
X-Spam-Score: -1.9 (-)
X-Debbugs-Envelope-To: 11085
Cc: 11085 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.6 (--)

Hi, 

Thanks for replying.  I am aware of bc, dc etc.  And in fact that was what I
did to work around (used bc), but it seems like unnecessary feature removal
when the underlying crypto library the tool is calling to actually do the
work is more natively working with hex (binary).

Sorry about getting off on the wrong foot with the "stupid" word mixed into
my thought.

I have been using unix exclusively since 1989, and yes I am a fan of the
unix philosophy.  I would qualify "it is possible to use other tools to work
around the lack of this feature" to more the tools are scalable,
conveniently pluggable etc.  And convenient pluggability applies IMO.

Eg lets say od can output in different formats (-tx1 I use commonly if I
need convert a file into something suitable to chain with some other crypto
command line tool) ...  you "could" no doubt work around that with awk, perl
or maybe even bc if you were creative, but it just makes things less
convenient to chain if the default or only output is not directly
compatibile with the main consuming next in the chain tools natural, default
or only input...

Adam

On Sun, Mar 25, 2012 at 09:54:39AM +0200, Jim Meyering wrote:
>Adam Back wrote:
>> Which is stupid because in most cryptographic applications, which is the
>> main practical use of factor, if people are going to include this in
>> distrubitons, use hexadecimal.  The underlying crypto library obviously
>
>A feature request that starts with "your implementation is stupid..."
>generally doesn't get far, even when it has merit.
>
>What would be near-sighted (I wouldn't say "stupid")
>would be to add explicit support for hexadecimal input
>when you can get the same effect via your shell:
>
>  factor $((0x1fffffffffffffff))
>
>If the input is larger than 2^64, use bc or dc:
>
>  factor $(echo 'ibase=16; FFFFFFFFFFFFFFFFF' |bc)
>
>
>> supports hex and its is more native number system anyway, so please enable
>> hex numbers.  eg 0xF it might be nice if the factors were in the same base
>> as the input, or if there was a flag to control the output radix...
>
>You might have heard about the Unix Philosophy?
>It is about connecting tools like factor and bc or your shell
>so that we don't have to duplicate base-conversion functionality
>in every tool that accepts an integer input.  Similarly, if you
>require hexadecimal output, use printf %x for small numbers or
>bc/dc/perl/python to convert.




Information forwarded to bug-coreutils@HIDDEN:
bug#11085; Package coreutils. Full text available.

Message received at 11085 <at> debbugs.gnu.org:


Received: (at 11085) by debbugs.gnu.org; 25 Mar 2012 08:26:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 25 04:26:01 2012
Received: from localhost ([127.0.0.1]:37457 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1SBilz-0000gc-UO
	for submit <at> debbugs.gnu.org; Sun, 25 Mar 2012 04:26:01 -0400
Received: from mx.meyering.net ([88.168.87.75]:53017)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <jim@HIDDEN>) id 1SBilk-0000gH-9a
	for 11085 <at> debbugs.gnu.org; Sun, 25 Mar 2012 04:25:58 -0400
Received: from rho.meyering.net (localhost.localdomain [127.0.0.1])
	by rho.meyering.net (Acme Bit-Twister) with ESMTP id 45D1660118;
	Sun, 25 Mar 2012 09:54:39 +0200 (CEST)
From: Jim Meyering <jim@HIDDEN>
To: Adam Back <adam@HIDDEN>
Subject: Re: bug#11085: factor only supports decimal numbers, doh
In-Reply-To: <20120324150711.GA24123@HIDDEN> (Adam Back's
	message of "Sat, 24 Mar 2012 16:07:11 +0100")
References: <20120324150711.GA24123@HIDDEN>
Date: Sun, 25 Mar 2012 09:54:39 +0200
Message-ID: <87aa35yv28.fsf@HIDDEN>
Lines: 29
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -1.9 (-)
X-Debbugs-Envelope-To: 11085
Cc: 11085 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -1.9 (-)

Adam Back wrote:
> Which is stupid because in most cryptographic applications, which is the
> main practical use of factor, if people are going to include this in
> distrubitons, use hexadecimal.  The underlying crypto library obviously

A feature request that starts with "your implementation is stupid..."
generally doesn't get far, even when it has merit.

What would be near-sighted (I wouldn't say "stupid")
would be to add explicit support for hexadecimal input
when you can get the same effect via your shell:

  factor $((0x1fffffffffffffff))

If the input is larger than 2^64, use bc or dc:

  factor $(echo 'ibase=16; FFFFFFFFFFFFFFFFF' |bc)


> supports hex and its is more native number system anyway, so please enable
> hex numbers.  eg 0xF it might be nice if the factors were in the same base
> as the input, or if there was a flag to control the output radix...

You might have heard about the Unix Philosophy?
It is about connecting tools like factor and bc or your shell
so that we don't have to duplicate base-conversion functionality
in every tool that accepts an integer input.  Similarly, if you
require hexadecimal output, use printf %x for small numbers or
bc/dc/perl/python to convert.




Information forwarded to bug-coreutils@HIDDEN:
bug#11085; Package coreutils. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 24 Mar 2012 18:32:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 24 14:32:22 2012
Received: from localhost ([127.0.0.1]:37140 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1SBVl1-0006N2-Qv
	for submit <at> debbugs.gnu.org; Sat, 24 Mar 2012 14:32:22 -0400
Received: from eggs.gnu.org ([208.118.235.92]:58488)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <adam.back@HIDDEN>) id 1SBT0Q-0001Qb-No
	for submit <at> debbugs.gnu.org; Sat, 24 Mar 2012 11:36:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <adam.back@HIDDEN>) id 1SBSWQ-0001ln-A4
	for submit <at> debbugs.gnu.org; Sat, 24 Mar 2012 11:04:51 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.2
Received: from lists.gnu.org ([208.118.235.17]:33059)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <adam.back@HIDDEN>) id 1SBSWQ-0001lj-6m
	for submit <at> debbugs.gnu.org; Sat, 24 Mar 2012 11:04:50 -0400
Received: from eggs.gnu.org ([208.118.235.92]:39030)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <adam.back@HIDDEN>) id 1SBSWO-0003Io-I7
	for bug-coreutils@HIDDEN; Sat, 24 Mar 2012 11:04:49 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <adam.back@HIDDEN>) id 1SBSWM-0001lT-Ql
	for bug-coreutils@HIDDEN; Sat, 24 Mar 2012 11:04:47 -0400
Received: from mail-wg0-f49.google.com ([74.125.82.49]:37207)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <adam.back@HIDDEN>) id 1SBSWM-0001l8-Kg
	for bug-coreutils@HIDDEN; Sat, 24 Mar 2012 11:04:46 -0400
Received: by wgbdr1 with SMTP id dr1so2101935wgb.30
	for <bug-coreutils@HIDDEN>; Sat, 24 Mar 2012 08:04:43 -0700 (PDT)
Received: by 10.180.88.199 with SMTP id bi7mr5433436wib.12.1332601483545;
	Sat, 24 Mar 2012 08:04:43 -0700 (PDT)
Received: from netbook (c107-41.i07-27.onvol.net. [92.251.107.41])
	by mx.google.com with ESMTPS id ff2sm38672097wib.9.2012.03.24.08.04.41
	(version=TLSv1/SSLv3 cipher=OTHER);
	Sat, 24 Mar 2012 08:04:42 -0700 (PDT)
Received: by netbook (Postfix, from userid 204881528)
	id A036334029D; Sat, 24 Mar 2012 16:07:12 +0100 (CET)
Received: by eee (hashcash-sendmail, from uid 204881528);
	Sat, 24 Mar 2012 16:07:11 +0100
Date: Sat, 24 Mar 2012 16:07:11 +0100
From: Adam Back <adam@HIDDEN>
To: bug-coreutils@HIDDEN
Subject: factor only supports decimal numbers, doh
Message-ID: <20120324150711.GA24123@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Disposition: inline
User-Agent: Mutt/1.5.21 (2010-09-15)
X-Hashcash: 1:20:120324:bug-coreutils@HIDDEN::bYbJ9A70ORHxtmq1:0000000000000000
	0000000000000000000000003QSV
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 208.118.235.17
X-Spam-Score: -1.1 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sat, 24 Mar 2012 14:32:06 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -1.1 (-)

Which is stupid because in most cryptographic applications, which is the
main practical use of factor, if people are going to include this in
distrubitons, use hexadecimal.  The underlying crypto library obviously
supports hex and its is more native number system anyway, so please enable
hex numbers.  eg 0xF it might be nice if the factors were in the same base
as the input, or if there was a flag to control the output radix...

Adam




Acknowledgement sent to Adam Back <adam@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-coreutils@HIDDEN. Full text available.
Report forwarded to bug-coreutils@HIDDEN:
bug#11085; Package coreutils. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.