T.R | Title | User | Personal Name | Date | Lines |
---|
1516.1 | | BEING::EDP | Always mount a scratch monkey. | Wed Nov 06 1991 09:11 | 17 |
| Re .0:
Percent of what? If you have two numbers, x and y, and what to find
out what percent x is of y, then use the command:
WRITE SYS$OUTPUT x*100/y
That's equivalent to multiplying x by 100 and dividing by y. That will
truncate the answer. You can get more decimal places by multiplying by
a thousand or more and mentally placing a decimal point in the answer,
but at some point you will run into the limitation where you have
multiplied x by something too big, so that it exceeds 2147483647, the
largest positive integer DCL can handle. You can also get the answer
rounded off instead of truncated by using (x*whatever+y/2)/y.
-- edp
|
1516.2 | percentages? | ZFC::deramo | I've seen it raining fire in the sky. | Wed Nov 06 1991 09:28 | 51 |
| > Could somebody please let me know how to figure percent using DCL.
You can do integer arithmetic with
$ write sys$output 1700 / 39
43
So 17 is roughly 43% of 39. Of course, the division truncates
instead of rounding off, as you can see with
$ write sys$output 99 / 10
9
To get less than half to truncate, and half or more to round up,
you can add in half of the denominator...
$ write sys$output (99 + 5) / 10
10
In a case like 39, you can't take half of it and still be an integer
but you can double both numerator and denominator, with something like
$ write sys$output (2 * 17 * 100 + 39) / (2 * 39)
44
So it would round up. (Note: 17 is 43.5897...% of 39). That is kind
of a mess to type in, though. If you add an extra 0 to both numerator
and denominator of the fraction, the 39 becomes a 390 and is now even
and can be halved
$ write sys$output (17000 + 390/2) / 390
44
For more decimal places, multiply by a power of ten before dividing
(be extremely careful mixing this with the + 390/2 method)
$ write sys$output 1700 * 1000 / 39
43589
(corresponds to 43.589% (which is truncated)) or
$ write sys$output (1700 * 1000 * 10 + 390/2) / 390
43590
(corresponds to 43.590% (which is rounded up)).
Dan
p.s. Truncation, rounding down and rounding up all refer to how DCL
behaves with positive integers, not negative ones. I haven't looked
into that.
|
1516.3 | | ZFC::deramo | I've seen it raining fire in the sky. | Wed Nov 06 1991 09:29 | 3 |
| Oops, notes collision. :-)
Dan
|
1516.4 | note collision insurance policy | STAR::ABBASI | | Wed Nov 06 1991 10:14 | 14 |
| ref .3
ok, that is it, Dan: i've tallied the number of times you 'note collided'
and it seems according to my calculations that you've just broke
the record and just exceeded the maximum allowable collision per person.
so we are therefore will be raising your note usage insurance rates
premium to cover medical coverage of injured notes.
this time it seems no note got hurt, but iam afraid that one of those days,
a major notes collision might occur, and that might result in one or more
notes might get hurt real bad, i cant bear the thought of that.
/nasser
|
1516.5 | | ZFC::deramo | I've seen it raining fire in the sky. | Wed Nov 06 1991 12:12 | 1 |
| re .-1 :-)
|
1516.6 | Let's call a code a code | VMSDEV::HALLYB | Fish have no concept of fire | Wed Nov 06 1991 12:20 | 5 |
| For those of you not "in the know", Dan D'eramo is actually a 92MB LISP
program executing in Hudson. That's why it collides with humans, and
tends to frequent the more scientific conferences.
John
|
1516.7 | %LISP-I-SPELL | ZFC::deramo | I've seen it raining fire in the sky. | Wed Nov 06 1991 15:22 | 7 |
| > For those of you not "in the know", Dan D'eramo is actually a 92MB LISP
> program executing in Hudson. That's why it collides with humans, and
> tends to frequent the more scientific conferences.
Dan spells his last name "D'Eramo" with a capital "E".
Dan
|