SCOUG-Programming Mailing List Archives
Return to [ 15 |
February |
2005 ]
>> Next Message >>
Content Type: text/plain
Benedict G.Archer wrote:
>
> two cents from a lurker:
Ben, great to hear from you! What's going on up there?
> J supports exact calculations using a syntax for a rational number,
> numerator r denominator. The operator that creates the exact
> representation of a decimal (or any base) value is 'x:'. For example,
>
> 17%83 yields 0.204819 (the divide operator in J is %)
> x: 17%83 gives 17r83
> and
> x: 13 + 17%83 gives 1096r83
> x: 13 + 0.204819 gives 5220261405187r395330023470
> and
> x: (11%3) * (4%7) gives 44r21 (some parens are needed)
Hmm. Can I multiply two r values, for example can I do the following?
x: 2r3 * 4r5
which should yield 8r15
Also, is there a kind of "fractional rounding" (my term) so that
x: 1.333333333
would yield 4r3?
> another syntax for exact calculations appends an x, e.g.,
> 44%21 gives 2.09524...
> 44%21x gives 44r21
Rewriting my last example above, would
1.333333333x
result in 1333333333r1000000000 or 4r3?
Good info, thanks Ben.
- Peter
=====================================================
To unsubscribe from this list, send an email message
to "steward@scoug.com". In the body of the message,
put the command "unsubscribe scoug-programming".
For problems, contact the list owner at
"postmaster@scoug.com".
=====================================================
>> Next Message >>
Return to [ 15 |
February |
2005 ]
The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA
Copyright 2001 the Southern California OS/2 User Group. ALL RIGHTS
RESERVED.
SCOUG, Warp Expo West, and Warpfest are trademarks of the Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of International
Business Machines Corporation.
All other trademarks remain the property of their respective owners.
|