tech-userlevel archive

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

Re: silly behavior of factor(6)



On Mon, Apr 26, 2010 at 09:18:33AM -0400, Christopher Berardi wrote:
 > But, in math many times base cases are defined. For example, when
 > dealing with Fibonacci numbers Fib(0) = 0 and Fib(1) = 1 even
 > though nothing there is nothing prior in the sequence to generate
 > those two.
 > 
 > So why couldn't we define factor(0) = 0 and factor(1) = 1 even if
 > in the strictest sense they may not be factorable?

Because in math these base cases are not defined and the candidate
definition for zero is particularly problematic.

 > Also, why are we limiting to Z+?

No clear reason.

 > The manpage states it can factor
 > -2147483648 to 2147483647, but when I try to factor -10, it gives
 > one of two errors (because apparently a negative number can't be
 > the first number factored):
 > 
 >      $ factor -10
 >      factor: unknown option -- 1
 >      usage: factor [value ...] 
 > 
 >      $ factor 10: -10 
 >      10: 2 5
 >      factor: negative numbers aren't permitted.

I fixed the man page the other day to match the current behavior.
However, the first issue you see is because of getopt; factor -- -10
behaves as expected.

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


Home | Main Index | Thread Index | Old Index