From owner-aurora-editor@sfu.ca Sat May 3 15:29:21 1997 Message-Id: <199705031620.QAA01029@dmbsdi.datamar.com.ar> Comments: Authenticated sender is From: "Walter M. Reznik" To: aurora-editor@sfu.ca Date: Sat, 3 May 1997 16:03:25 +0000 Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT Subject: Real Numbers Reply-To: wala@datamarkets.com.ar X-Confirm-Reading-To: wala@datamarkets.com.ar X-Pmrqc: 1 Priority: normal X-Mailer: Pegasus Mail for Win32 (v2.53/R1) Hello. I wrote this function that performs a real division, with a long number of decimal places. It only does it with integer numbers, so you can do (div 10 3) but not (div 10 2.5). It returns a string with the result. It is useful for calculating percentages and such. Below is a dialog box that askes two numbers and then invokes the function. I think it would be interesting to develope a set of functions to do real numbers math. bye. Walter- //----------- here it goes.... --------------- function div(a b) int_part = a / b reminder = a mod b ret = concat int_part '.' while reminder > 0 and (length ret) < 32 do digit = (reminder * 10) / b ret = concat ret digit reminder = reminder * 10 - digit * b endwhile return ret end //-------------------------------------------------------------------- // Edit and File Manager windows //-------------------------------------------------------------------- object edit_fmgr key variable num1 variable num2 num1 = 0 num2 = 0 dialog "Division" 35 7 "c" field "First number: >" 3 2 15 field "Second number: >" 3 4 15 button "O&k" 12 6 10 if (getdialog ref num1 ref num2) == "Ok" msgbox (div num1 num2) (num1+" / "+num2) end end