Code, str, and decimals

Closed Forum - older posts now retired. This forum is read only. You can search and view posts in this forum but you cannot reply or create new posts in this forum.
Post Reply
Joshua Morgan

Code, str, and decimals

#1

Post by Joshua Morgan » Fri May 31, 2002 1:32 pm

Mr. Appell-

I understand the basic math functions of the code command, such as:

> or -,/,*,^

I have two questions about it's limits:

First, are there any other math functions it can do, or is it limited to +,-,/,* and ^?

Second, is there any way to get it to produce decimal numbers? For example:

> should display 4.5 but instead it rounds the number to 5. Is there any way to bypass this limitation?

Thanks as usual and keep up the good work!

Joshua Morgan

Michael Appell

Re: Code, str, and decimals

#2

Post by Michael Appell » Fri May 31, 2002 8:37 pm

1. First, are there any other math functions it can do, or is it limited to +,-,/,* and ^?

No - there are many, many others (well over 100 including the transcendental functions). So, I'm not sure if there is something in particular that you are looking for.

2. > should display 4.5 but instead it rounds the number to 5. Is there any way to bypass this limitation?

Yes there is. The str function takes two additional parameters where the first is the total number of digits including the decimal point and the second is the number of digits to the RIGHT of the decimal point. For example, a number like 54321.89 takes 8 characters in all (when you include the decimal point) and two are to the right of the decimal point. Therefore, this may be expressed as str(54321.89, 8, 2) Of course you may also express it as a number more than 8 like str(54321.89, 9, 2) and spaces will precede the number so that all numbers may easily be right justified.

- Thanks as usual and keep up the good work!

Thanks.
Mike

Michael Appell

Re: Code, str, and decimals

#3

Post by Michael Appell » Fri May 31, 2002 8:59 pm

By the way,

I should mention regarding the math that one of the powerful features in A1-Law are the simple arithmetic operations. Consider the power in automating mileage computations (ie: cents per mile) from a form letter. Consider the following example:

>

Total Miles: >
Total Mileage Fee at .34/mile: $>

Since A1-Law may "do math" and compute values, there is no need for staff to have to use a calculator to computer mileage or any other totals or grand totals for that matter. All of this may be calculated with form letter commands.

Finally ....
Although A1-Law does contain several hundred mathematical functions, I did not feel it necessary to document them all in a manual that is already approaching 1,000 pages. But, if the demand is there I may.

Mike

Michael Lerner

Re: Code, str, and decimals

#4

Post by Michael Lerner » Mon Jun 03, 2002 2:17 pm

Dear Michael,

I am trying to figure out the best way to compute a depo fee.

We have X minutes of preparation (memory 41) + Y minutes of depo (memory 42). If we charge $200/hour for a deposition, would the coding work as the following to have memory cell 51 as the total?:

>

So you would have (X +Y) minutes /60 minutes * 200.

We need decimal values with the numbers produced or it rounds off too soon.

If you use a number greater than the number of digits, will that cause problems? Say 9, 5 when the number is only 4.5?

Thanks!

Sincerely,
Michael Lerner
Lerner, Moore, Mammano, Strasser, and Silva
www.injuryatwork.com
(909) 889-1131

Michael Appell

Re: Code, str, and decimals

#5

Post by Michael Appell » Mon Jun 03, 2002 9:05 pm

Please use the following code (notice the division of 200 by 60 so that the hourly rate is converted to the minute rate). Also, please take great care that your staff enters the numbers in minutes and not hours since the formula I have provided below converts minutes.

>

2. We need decimal values with the numbers produced or it rounds off too soon.

The above rounds to the nearest penny since it's 9, 2 there will be 2 digits to the right of the decimal point and up to 6 to the left. Therefore, you may have a number as large as 999999.99 If you expect a fee in the million dollar range, you would simply change the 9 to a 10.

3. If you use a number greater than the number of digits, will that cause problems? Say 9, 5 when the number is only 4.5?

If you use str(4.5, 9, 5) this does not cause a problem at all since you are saying total characters will be 9 and 5 will be to the right of the decimal point, therefore, 3 will be to the left of the decimal point (or a number as large as 999.99999). Of course I would say that most always you will not need more than 2 digits to the right of the decimal point.

But, in answer to your question, if you had a number that was more digits and cause overflow like: Str(12345, 4, 2) then A1-Law will display ***** rather than a portion of the number since the above only allows for one digit to the left side of the decimal point and we have a number that is much much larger than 9.

Mike

Post Reply