tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: silly behavior of factor(6)



On Wed, Apr 28, 2010 at 10:28:30PM +0200, Kristaps Dzonsons wrote:
>>>> I'm currently inclined to change it to error on 0, print a leading -1
>>>> for negatives, and leave the rest alone...
>>> -1 isn't a prime factor.  "Unless it is."  I'll let this speak for   
>>> itself as to the can of worms opened by introducing x<1 as input 
>>> without  having factor.6 contain a lesson in number fields.  Please, 
>>> please keep  input in N.
>>
>> And 1 has no prime factors either. That's great, but the whole point
>> of this thread is to strike a balance between what's strictly
>> meaningful and what makes the most ad hoc sense.
>
> I agree, so "1: " makes sense (it has no prime factors).

Not really; it doesn't make sense to ask to factor 1.

> But printing anything next to "0: " is wrong (it has infinite prime
> factors),

no it doesn't, in that there exists no set of prime numbers such that
their product is 0.

Printing 0 makes some sense because it's the minimal set of minimal
numbers whose product is 0. Printing nothing is wrong because the
product of an empty set of numbers more or less has to be taken as 1

> and printing anything next to "-x: " is misleading unless the
> operator has a good grounding in theory.

That's debatable.

Besides, one of the pertinent considerations is (or should be) what
happens given e.g.  "ls -l | awk '{ print $5 }' | factor", where some
of the numbers may be inappropriate but it's not necessarily desirable
to choke on those and not print results for the rest.

(I can't think of any reason anyone would want to factor the sizes of
their files, but there are plenty of other sources of numbers around,
and the reason this thing is in games is that it has no clear
application anyway...)

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index