Thread: [q-lang-users] Unparse on Rationals
Brought to you by:
agraef
From: Rob H. <hub...@gm...> - 2006-06-22 00:32:41
|
At the moment, unparse on (positive) Rational values always produces a value of the form N%D (well, pending the change to (%) from (over) anyway). Is this what is really desired? I wondered whether it would be preferable to present, for example: 3%1 as just 3 The LHS has the advantage of looking like the rational it is The RHS is clearly simpler 11%5 as 2+1%5 The LHS is simpler this time The magnitude of the RHS more obvious (i.e. that it's "2 and a bit") I prefer the RHS in both cases. Comments welcome. Thanks, Rob. |
From: John C. <co...@cc...> - 2006-06-22 00:50:06
|
Rob Hubbard scripsit: > I wondered whether it would be preferable to present, for example: > > 3%1 as just 3 > The LHS has the advantage of looking like the rational it is > The RHS is clearly simpler I prefer the RHS here, but worry about people being misled by it. Would you want to see 3+0*i as 3 also? > 11%5 as 2+1%5 > The LHS is simpler this time > The magnitude of the RHS more obvious (i.e. that it's "2 and a bit") I definitely prefer the LHS in this case, because 2+1%5+3+2%5*i is completely misleading (or would it be parenthesized by the unparser?) -- John Cowan <co...@cc...> http://www.ccil.org/~cowan One time I called in to the central system and started working on a big thick 'sed' and 'awk' heavy duty data bashing script. One of the geologists came by, looked over my shoulder and said 'Oh, that happens to me too. Try hanging up and phoning in again.' --Beverly Erlebacher |
From: Rob H. <hub...@gm...> - 2006-06-22 00:59:56
|
John Cowan wrote: > Rob Hubbard scripsit: > > >> I wondered whether it would be preferable to present, for example: >> >> 3%1 as just 3 >> The LHS has the advantage of looking like the rational it is >> The RHS is clearly simpler >> > > I prefer the RHS here, but worry about people being misled by it. > Would you want to see 3+0*i as 3 also? > > I suppose that's related to the normal form problem that you mentioned before. Well, I'd like these to be mutually consistent: both simplified, or neither simplified. >> 11%5 as 2+1%5 >> The LHS is simpler this time >> The magnitude of the RHS more obvious (i.e. that it's "2 and a bit") >> > > I definitely prefer the LHS in this case, because 2+1%5+3+2%5*i is > completely misleading (or would it be parenthesized by the unparser?) > It would have to be (2+1%5)+(3+2%5)*i. Yes, I think I prefer 11%5+17%5*i in this case too. Rob. |
From: Albert G. <Dr....@t-...> - 2006-06-22 01:18:19
|
John Cowan wrote: > Rob Hubbard scripsit: > >>I wondered whether it would be preferable to present, for example: >> >> 3%1 as just 3 >> The LHS has the advantage of looking like the rational it is >> The RHS is clearly simpler No, I definitely have to oppose this. :) It should be clear to see that it is a rational number, so 3%1, not 3. For the same reason, a complex number is unparsed as X+Y*i even if Y is zero. (Currently I do simplify the case of a zero real part, though, in this case the number would be printed as just Y*i, but that also makes it clear that it's a complex number.) >> 11%5 as 2+1%5 >> The LHS is simpler this time >> The magnitude of the RHS more obvious (i.e. that it's "2 and a bit") > > I definitely prefer the LHS in this case, because 2+1%5+3+2%5*i is > completely misleading (or would it be parenthesized by the unparser?) Yes the LHS, again. If you need a better format to see the magnitude, well that's what ratutils::str_mixed is for. Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |
From: Rob H. <hub...@gm...> - 2006-06-22 08:05:48
|
On 22/06/06, Albert Graef <Dr....@t-...> wrote: > John Cowan wrote: > > Rob Hubbard scripsit: > > > >>I wondered whether it would be preferable to present, for example: > >> > >> 3%1 as just 3 > >> The LHS has the advantage of looking like the rational it is > >> The RHS is clearly simpler > > No, I definitely have to oppose this. :) It should be clear to see that > it is a rational number, so 3%1, not 3. For the same reason, a complex > number is unparsed as X+Y*i even if Y is zero. (Currently I do simplify > the case of a zero real part, though, in this case the number would be > printed as just Y*i, but that also makes it clear that it's a complex > number.) Thanks. That was the sort of answer I was after: definite. I was still not certain of the intention behind unparse, i.e. whether just the semantic value should be presented to the user as simply as possible, or whether the type should also be indicated. Clearly it is the latter. > >> 11%5 as 2+1%5 > >> The LHS is simpler this time > >> The magnitude of the RHS more obvious (i.e. that it's "2 and a bit") > > > > I definitely prefer the LHS in this case, because 2+1%5+3+2%5*i is > > completely misleading (or would it be parenthesized by the unparser?) > > Yes the LHS, again. If you need a better format to see the magnitude, > well that's what ratutils::str_mixed is for. Okay. Similarly, thanks. Rob. |