Topic: Simple math using N-registers (1 of 20), Read 181 times
Conf: VEDIT Macro Language Support
From: Dewayne Cheramie
Date: Monday, April 16, 2001 07:56 AM

Is there any way to do simple math functions using N-registers. I use V-edit exclusively to edit CNC programs and it sure would be nice to be able to add, subtract, multiply and divide those numbers in V-edit.

Dewayne

 


Topic: Simple math using N-registers (2 of 20), Read 157 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Wednesday, April 18, 2001 04:54 AM

>it sure would be nice to be able to add,
>subtract, multiply and divide those numbers in V-edit.

Off course it is possible.
Where is your problem with + - * / in VEDIT?


Christian

 


Topic: Simple math using N-registers (3 of 20), Read 168 times
Conf: VEDIT Macro Language Support
From: Dewayne Cheramie
Date: Wednesday, April 18, 2001 12:12 PM

Maybe I am doing something wrong, but when I divide an N-register with 1 in it by an N-register with 3 in it, I get 0. That is not very useful to me. I need to work with real numbers, not just integers.

Dewayne

 


Topic: Re: Simple math using N-registers (4 of 20), Read 183 times
Conf: VEDIT Macro Language Support
From: Fritz Heberlein
Date: Wednesday, April 18, 2001 02:21 PM

ybe I am doing something wrong, but when I divide an N-register with
> 1 in it by an N-register with 3 in it, I get 0. That is not very
> useful to me. I need to work with real numbers, not just integers.

Yes, that's a weak point of the v+ calculator. Scott Lambert has shown
one possible workaround in his addcol.vdm, see
http://carver.pinc.com/~slambert/macros.htm

Fritz

 


Topic: Re: Simple math using N-registers (5 of 20), Read 160 times
Conf: VEDIT Macro Language Support
From: Steve Rawling
Date: Sunday, December 08, 2002 12:56 AM

Yes I too have sometimes wanted to incorporate simple real number arithmetic into my vdms

Because it cant be done I can often get around it by either a prior manipulation of the input file by first loading it into excel, passing and adding columns or rows for the real number computations or else I format the output file to allow easy parsing into excel where I then carry out any computations needed.


I know the complete programmer would say that I should be using C to do such things, but I'm one of those guys who have learnt to do "amazing stuff" with vdms but have never learnt C!!! I think there is a few of us out here.

So... I often wonder what it would take to get vedit to handle real number +,-,*,/ in its numeric registers.

Steve

 


Topic: Re: Simple math using N-registers (6 of 20), Read 172 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Sunday, December 08, 2002 03:59 PM

At 12:57 AM 12/8/2002, you wrote:
>So... I often wonder what it would take to get vedit to handle real number +,-,*,/ in its numeric registers.

VEDIT currently can convert floating point numbers into ASCII; this isn't really documented because it is only part of our EBCDIC conversion software.

We have no plans to add general floating point math to VEDIT.

In most cases, you don't really need it either. Lets say you want to add 1.2345 to 9.45. Since the most precise number has 4 digits after the decimal point, you simply multiply all number by 10,000, add them, and then divide by 10,000. The remainder of the division gives you the digits after the decimal point.

The upcoming VEDIT Pro64 has 64-bit integer math - about 20 digits of precision.

I suspect we will someday add full floating point support ( C
libraries can handle the math), but it just doesn't seem like a priority right now.

Ted.

 


Topic: Re: Simple math using N-registers (7 of 20), Read 148 times
Conf: VEDIT Macro Language Support
From: Steve Rawling
Date: Tuesday, December 31, 2002 10:44 PM

>...Lets
>say you want to add 1.2345 to
>9.45. Since the most precise
>number has 4 digits after the
>decimal point, you simply
>multiply all number by 10,000,
>add them, and then divide by
>10,000. The remainder of the
>division gives you the digits
>after the decimal point.
>

Is there a similar simple way to MULTIPLY 1.2345 by 9.45?

>The upcoming VEDIT Pro64 has
>64-bit integer math - about 20
>digits of precision.

I assume that means 20 digits of precision with the math tools already available vpw6, Yes?

Steve

 


Topic: Re: Simple math using N-registers (8 of 20), Read 155 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Wednesday, January 01, 2003 12:20 PM

>From: "Steve Rawling"
>
>[From Ted:]
>>...Lets say you want to add 1.2345 to 9.45. Since the most precise
>>number has 4 digits after the decimal point, you simply
>>multiply all number by 10,000, add them, and then divide by
>>10,000. The remainder of the division gives you the digits
>>after the decimal point.
>
>Is there a similar simple way to MULTIPLY 1.2345 by 9.45?


Of course:

1.2345 x 9.45

Count the number of digits after the decimal points and add them:

4 + 2 = 6

Remove the decimal points and multiply the remaining numbers:

12345 x 945 = 11666025

Insert a decimal point at the calculated position from the right
(here 6th):

11.666025

Done.


That should be easy to implement via a VDM macro.


Christian

 


Topic: Re: Simple math using N-registers (9 of 20), Read 168 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Tuesday, November 11, 2003 04:08 PM

I wrote a macro which can handle simple floating point math.
(addition, subtraction, multiplication and division):

http://ziemski.privat.t-online.de/vedit/macros/floatmath.vdm

It's a quick shot for now and may contain bugs.
And there is no error handling yet...

For easy testing you can use the following interactive macro (needs
the Windows version of VEDIT):

http://ziemski.privat.t-online.de/vedit/macros/floatdemo.vdm


Christian

 


Topic: Re: Simple math using N-registers (10 of 20), Read 168 times
Conf: VEDIT Macro Language Support
From: Steve Rawling
Date: Friday, January 10, 2003 06:54 AM

// FLOATDEMO.VDM Ch. Ziemski 04.01.2003
and
// FLOATMATH.VDM Ch. Ziemski 03.01.2003,04.01.2003

Gee Christian, that is excellent!! thanks.


I am very grateful for your macro, and I will definitely use it as is, however I make the following observations..

Regarding Division
I tested 14.425 / 12.687 with a precision of division = 6

and it gave 1.136990

Calculating this expression using a calculator set to a precision of 9 places gives 1.136990620

It seems floatmath.vdm rounds down(i.e.truncates) rather rounds to the preset precision.

Several other examples show the same. eg 48 / 7 set to 2 gives 6.58.


Regarding Multiplication

It seems that multiplication gives the full number of figures required by "floating" display. ie 12.123*12.234 = 148.212782 and 12.12*12.23= 148.2276. That is OK, but I suggest that if a value existing in #103 the answer could be made to be rounded to that precision.

I also note that if the "floating" decimal precision requires more than 9 significant figures the calc fails, incorrectly showing 0.0000 as the answer.

Steve

 


Topic: Re: Simple math using N-registers (11 of 20), Read 172 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Friday, January 10, 2003 10:09 AM

At 06:54 AM 1/10/2003, you wrote:

>I also note that if the "floating" decimal precision requires more than 9 significant figures the calc fails, incorrectly showing 0.0000 as the answer.

VEDIT's current 32-bit internal math limits you to 9 digits. The upcoming VEDIT Pro64 uses 64-bit math and would have about 18 digit precision.

BTW - A VEDIT 6.1 (32-bit) beta-test is available now on our website.

Cheers,


Ted.
-------------------------------------------------------------------------
Ted Green (ted@...) Greenview Data, Inc.
Web: http://www.... PO Box 1586, Ann Arbor, MI 48106
Tel: (734) 996-1300 Fax: (734) 996-1308 VEDIT - Text/Data/Binary Editor

 


Topic: Re: Simple math using N-registers (13 of 20), Read 189 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Friday, January 10, 2003 04:12 PM

Steve:

You wrote:

>I am very grateful for your macro, and I will definitely use it as is,
>however I make the following observations..
>
>Regarding Division
>I tested 14.425 / 12.687 with a precision of division = 6
>
>and it gave 1.136990
>
>Calculating this expression using a calculator set to a precision of 9
>places gives 1.136990620

Don't forget: VEDIT isn't a floating point calculator!

>It seems floatmath.vdm rounds down(i.e.truncates) rather rounds to the
>preset precision.

Yes.
That is why the demo says: "Precision on division (no rounding): "


I tried to implement rounding yet, with some success.
But doing that, I again found out that it's absolutely not trivial to
have trustworthy results in the whole calculation due to this:
I'm not a mathematician.
And:
VEDIT isn't a floating point calculator!


It is definitely possible to do floating point math using only integer
capabilities (every computer does it), but IMHO it doesn't make sense
to try that with a VEDIT macro.

My macro only should be an example, demo or prototype for that.
It is *far away* from perfect!
Absolutely no error handling and so no overflow is detected.

You can use it as demo for playing around but you shouldn't trust the
evaluated results in productive environment!

Of course you can try to improve it by yourself, but be warned:
It's really not trivial! ;-)


Sorry for the bad news.

Christian

 


Topic: Re: Simple math using N-registers (14 of 20), Read 191 times
Conf: VEDIT Macro Language Support
From: Pauli Lindgren
Date: Monday, January 13, 2003 10:50 AM

On 1/10/2003 4:12:25 PM, Christian Ziemski wrote:
>
>It is definitely possible to
>do floating point math using
>only integer
>capabilities (every computer
>does it), but IMHO it doesn't
>make sense
>to try that with a VEDIT
>macro.

Maybe attempt to do floating point calculations with Vedit is not very good idea. But doing unlimited precision decimal calculation could be fun (in the similar fashion as the dc and bc calculators on Unix).
That is, perform the calculations using ascii strings, without converting them into integers.


-- Pauli Lindgren

 


Topic: Re: Simple math using N-registers (17 of 20), Read 192 times
Conf: VEDIT Macro Language Support
From: Steve Rawling
Date: Friday, January 31, 2003 10:07 PM

On 1/10/2003 4:12:25 PM, Christian Ziemski wrote:
>You can use it as demo for
>playing around but you
>shouldn't trust the
>evaluated results in
>productive environment!

Christian

Are you saying that your macro "floatmath.vdm" could sometimes give a mathematically incorrect result??


I guess it would be likely only in division yes?

If so, is there a predictable circumstance for error, such as some sort of repeatability.

I just read Ken's posting too and I'm drooling:-)

Steve

Steve

 


Topic: Re: Simple math using N-registers (18 of 20), Read 203 times
Conf: VEDIT Macro Language Support
From: Christian Ziemski
Date: Sunday, February 02, 2003 02:19 PM

>From: "Steve Rawling"
>
>On 1/10/2003 4:12:25 PM, Christian Ziemski wrote:
>>You can use it as demo for playing around but you shouldn't trust
>>the evaluated results in productive environment!
>
>Christian
>
>Are you saying that your macro "floatmath.vdm" could sometimes give a
>mathematically incorrect result??

Exactly.

If one or both numbers or the intermediate values are longer than
VEDIT's internal precision of 9 digits the result will be wrong.
Since there is no error handling you will not be warned about that.


Christian

 


Topic: beta / ProjMgr (12 of 20), Read 168 times
Conf: VEDIT Macro Language Support
From: Michael Baas
Date: Friday, January 10, 2003 10:53 AM

Hi,

I now you don't want bug reports about the ProjectMgr yet, so I won't
tell you ;-)

But I also have a suggestion: I always would have liked it if the
Xplor-Tab would switch to the directory of the currently edited file.
When dealing with projects this could be even better ;-)
Perhaps a general way to attack this request could be to just add a
"Goto file-dir"-button to the Xplor-Tab - pressing this button should
open the directory of the currently active file. And perhaps an
additional config could be used to control auto-activiation of current
dir when launching vedit with a filename as argument. And maybe you
could provide a possibility to define a "base-cirectory" for a project
which would also be shown in the xplor-tab...

Cheers

Michael

 


Topic: Math using floating Point within Vedit (15 of 20), Read 171 times
Conf: VEDIT Macro Language Support
From: Ken Jensen
Date: Sunday, January 19, 2003 01:32 AM

Jan 18, 2003
RE: Math using floating point numbers within Vedit

I also wanted to give Vedit floating point math. So I tried different
methods to learn which method is the easiest or fastest for Vedit.
Please note, all of my solutions place a ASCII string in a Vedit
text register. The string is an equation made of a floating point number
(ie +.00113 or -355000.) and a math operator and a second
floating point number. Then it passes the string to some type of a
program to solve the a math equation. Lastly return the result to a
location where Vedit can find it and put it back into a text register.




The Vedit Plus for MSDOS has some commands not found in
Vedit Plus for Windows. These commands allow user binary code to be
included with Vedit Plus and executed. The user writes an assembly
level subroutine. This assembly code includes reserved memory location
to pass an argument and return the result. Vedit Plus for MSDOS must do
Sys_Malloc(n) allocate a number of memory bytes
Sys_Block_Write(r,mem) copy user subroutine to above
Sys_Reg_Address(r) point to input argument location
Sys_Call(mem) execute user subroutine
Sys_Block_Read(r,mem1,mem2) return results back to Vedit Plus

My user subroutine for floating point equation uses the Intel
Binary Coded Decimal series of math instructions. The benchmark
for this method is .55 msec per equation.

I wrote a second user subroutine that uses the Intel floating point
coprocessor. The benchmark for this method is .42 msec per equation.
It is the fastest solution, but is not easy to use. A copy of this
is in a file called FPMATH09.ZIP


Another easy solution is to run an existing 3rd party program that does
floating point math. An example of a 3rd party is a MSDOS port of UNIX AWK.

Vedit Plus for MSDOS or Vedit Plus for Windows must
Write the string or equation to a RAMDISK file
Shell out and execute a 3rd party program or
Run AWK from Vedit with System("D:AWK -f D:MYTEST.AWK D:EQUATION.TXT",NOMSG=
)
The 3rd party program will read the equation, solve it,
write result to disk, and quit
Vedit Plus then reads the result from RAMDISK
by Reg_Load(r,"D:RESULT.TXT")

The benchmark for this method is 200 msec per equation.
Here is a sample of the simple MATH_AWK method
The AWK needed may be found at http://www.simtel.net/pub/pd/51371.html
run vedit -x MATH_AWK.VDM and then view the file RESULT.TXT

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
// FIRST LINE OF FILENAME MATH_AWK.VDM
//
Reg_Set(53,"355.")=09=09// set Y variable ready for arithmetic
Reg_Set(54,".113")=09=09// set X variable ready for arithmetic
Reg_Set(55," / ")=09=09// set math operator !!! WITH spaces !!!
=09=09=09=09// spaces are delimiters in AWK
Reg_Set(59,@53)=09=09=09// build equation with first variable
Reg_Set(59,@55,APPEND)=09=09// build equation with math operator
Reg_Set(59,@54,APPEND)=09=09// build equation with second variable
Reg_Save(59,"D:EQUATION.TXT",OK)=09// save source data to disk
//
System("D:AWK -f D:MYTEST.AWK D:EQUATION.TXT",NOMSG)=09// do math with AWK
//
Reg_Load(61,"D:RESULT.TXT")=09=09// get answer back to Vedit
QALLY=09=09=09=09=09// quit vedit
// LAST LINE OF FILENAME MATH_AWK.VDM
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D
# First Line of Filename MYTEST.AWK
{
if ($2 =3D=3D "+") answer =3D $1 + $3
if ($2 =3D=3D "-") answer =3D $1 - $3
if ($2 =3D=3D "*") answer =3D $1 * $3
if ($2 =3D=3D "/") answer =3D $1 / $3
if ($1 =3D=3D "=FB") answer =3D sqrt($2)
if ($1 =3D=3D "sin") answer =3D sin($2*3.1459/180)
print (answer) > "D:result.txt"
}
# Last Line of Filename MYTEST.AWK
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D



In the Vedit E-mail Newsletter Oct 23, 2001, Mr. Green writes that
Mr Tom Burt will try to write a Sendkey() function into Vedit. With
Sendkey() Vedit could;
write the floating point equation to the Windows clipboard
Sendkey() paste from clipboard to Windows program CALC.EXE
Sendkey() =3D or solve equation and return result
Sendkey() copy to clipboard
read the result back into Vedit from the clipboard

The benchmark for this method is unknown.




Mr Ziemski provided us with FLOATMATH.VDM. His method is to rescale the
floating point number into the smallest integer (the scale will be
variable to make the smallest number). Then pass the integer
equation to Vedit Plus for a solution. Then restore the result
integer back to a floating point from reusing the variable scale.
The benchmark for his method is 2.2 msec per equation.




A note to Mr. Ziemski,
Your macro FLOATMATH.VDM is good work.
Also about error handling to Mr. Ziemski.
My floating point subroutine also does NOT have error handling checking.
I found if it written to use a number 100 times the range of the numbers
that really sees, then I did not find errors. I use fixed scaling
(by 1,000,000,000,000,000,000) for 128 bit inputs then only keep 64 bits.
This should allow error checking to be easier. I did not try to write a
Vedit macro like yours because I estimated it would be too slow.
But you proved that 2.2 msec solution is not slow, it is good solution.
Thank you




A note to Mr. Green,
32 bit signed integer of Vedit Plus
MAX RESULT SQUARE ROOT of MAX RESULT SAFE ASCII INPUT RANG=
E
2,147,483,647 46,340 10,000 to .0001
64 bit signed integer of Vedit Pro64
MAX RESULT SQUARE ROOT of MAX RESULT SAFE ASCII INPUT RANG=
E
9,223,372,036,854,775,807 3,037,000,499 1,000,000,000 to .00000000=
1

32 bit signed integers make the safe ASCII input range too narrow for my
needs. However 64 bit signed integers found in old Intel coprocessors
and your future Vedit Pro64 meet my range requirements. I plan to write
a Vedit macro with fixed scaling (always by 1,000,000,000) of the ASCII
numeric string when Vedit Pro64 is released. I can benchmark Greenview
Data's use of 64 bit instructions against my use of the coprocessor
64 bit instructions (.42 msec per equation). I believe that myself and
other Vedit users like the quick action seen from assembly code.


Thank you



--=20
kenjen@... Ken Jensen Portland, Oregon USA
---------------------------------------------------------

 


Topic: Re: Math using floating Point within Vedit (16 of 20), Read 182 times
Conf: VEDIT Macro Language Support
From: Ted Green
Date: Monday, January 20, 2003 10:52 AM

At 01:35 AM 1/19/2003, you wrote:
>From: "Ken Jensen"
>RE: Math using floating point numbers within Vedit
>...
>
>My user subroutine for floating point equation uses the Intel
>Binary Coded Decimal series of math instructions. The benchmark
>for this method is .55 msec per equation.
>
>I wrote a second user subroutine that uses the Intel floating point
>coprocessor. The benchmark for this method is .42 msec per equation.
>It is the fastest solution, but is not easy to use. A copy of this
>is in a file called FPMATH09.ZIP

Ken:

Thank you very much for your contributions! Tom and I will study
it carefully after VEDIT 6.1 is released and we catch our breath.

We have already implemented some floating point code in VEDIT. It
is only used in our EBCDIC conversion software to convert floating
point (32 and 64 bit) binary numbers into ASCII. There currently is
no macro language access to it; although that would be easy to add.

Ted.

 


Topic: Re: Math using floating Point within Vedit (19 of 20), Read 162 times
Conf: VEDIT Macro Language Support
From: Steve Rawling
Date: Tuesday, January 13, 2004 05:01 AM

Regarding floating point math in vedit, I followed the recommendation to use an external command line floating point calculator.

So I wrote a macro to compile a list of arithmetic expressions, shell out to the command line , run the command line calculator with the list as an argument, then reenter vedit and read the command line calculators output file.

I found two that were OK, EVAL and CC but both unfortunately were not double precision floating point precision.

I recently discovered that 4NT does command line math to double precision math

From ftp://jpsoft.com/help/jphelp.chm

"Note: 4NT and Take Command use 64-bit arithmetic internally, i.e. each value (a "double") is represented by 64 bits: 1 for the sign, 11 for the exponent, 52 for the mantissa. The range of possible values is +/-1.7E308 (at least 15 digits of precision). "



Steve

 


Topic: Re: Math using floating Point within Vedit (20 of 20), Read 46 times
Conf: VEDIT Macro Language Support
From: Peter Rejto
Date: Friday, June 04, 2010 12:37 PM

On 1/13/2004 5:01:19 AM, Steve Rawling wrote:
>Regarding floating point math
>in vedit, I followed the
>recommendation to use an
>external command line floating
>point calculator.
>
>So I wrote a macro to compile a list of
>arithmetic expressions, shell out to the
>command line , run the command line
>calculator with the list as an argument,
>then reenter vedit and read the command
>line calculators output file.
>
>I found two that were OK, EVAL and CC
>but both unfortunately were not double
>precision floating point precision.
>
>I recently discovered that 4NT does
>command line math to double precision
>math
>
>From ftp://jpsoft.com/help/jphelp.chm
>
>"Note: 4NT and Take Command use 64-bit
>arithmetic internally, i.e. each value
>(a "double") is represented by 64 bits:
>1 for the sign, 11 for the exponent, 52
>for the mantissa. The range of possible
>values is +/-1.7E308 (at least 15 digits
>of precision). "
>
>
>
>Steve



Hello Steve,


Are you still interested in floating point calculations ?

I certainly would appreciate getting your macro.

I also would like to follow up

>the
>recommendation to use an
>external command line floating
>point calculator.

So may be somebody else could help with this.


Thanks to all,

-peter