Re: Scaled division and sqrt

2017-02-27 Thread Lindsay John Lawrence
Thanks Eric, I am going to have to play with those two particular built-in functions a bit more. Their use, especially '*/ was not intuitive to me. At first, or second, reading. Having just tried it... I am surprised that the 'sqrt* I implemented is quite a bit faster! than the built-in 'sqrt.

Re: Scaled division and sqrt

2017-02-27 Thread Alexander Burger
Hi Lindsay, > Are there scaled (fixed point) versions of division and sqrt in picolisp? I > may have missed them... The built-in '*/' function is both for multiplication *and* division. And 'sqrt' accepts an optional scale factor. For details, take a look at Rick's excellent article on the

Re: Scaled division and sqrt

2017-02-27 Thread Danilo Kordic
It seems You reimplemented `*/'. How about something like: # [name 'sqrt "isqrt"] # Somthing like that. [scl [if native 17 8]] [de sqrt [N] [list [isqrt (** 100 *Scl) N] 'E [- *Scl]] ] On 2/27/17, Joh-Tob Schäg wrote: > Now there are before there were not. > Am

Re: Scaled division and sqrt

2017-02-27 Thread Lindsay John Lawrence
Hi Danilo, Sorry, I do not follow this. Can you explain a bit more? Thanks! /Lindsay On Mon, Feb 27, 2017 at 3:32 AM, Danilo Kordic wrote: > It seems You reimplemented `*/'. > > How about something like: > # [name 'sqrt "isqrt"] # Somthing like that. > [scl [if

Re: Scaled division and sqrt

2017-02-27 Thread Lindsay John Lawrence
Hi Alex, I am missing something basic here that article is how I ended up writing the functions. With the functions I implemented I can write something like... : (scl 64) (format (sqrt* 2.0) *Scl) -> "1.4142135623730950488016887242096980785696718753769480731766797379" : (scl 64) (format

Re: Scaled division and sqrt

2017-02-27 Thread Erik Gustafson
Hi Lindsay, With the functions I implemented I can write something like... : (scl 64) (format (sqrt* 2.0) *Scl) -> "1.4142135623730950488016887242096980785696718753769480731766797379" 'sqrt' also accepts a 'scl' argument : (format (sqrt 2.0 1.0) *Scl) ->

Re: Scaled division and sqrt

2017-02-27 Thread Alexander Burger
Hi Lindsay, On Mon, Feb 27, 2017 at 06:28:15AM -0600, Erik Gustafson wrote: > With '*/', I like to think of it like this: for multiplication, the scale > factor is last, e.g. > >(*/ X Y Scl) > > For division, the scale factor comes first, e.g. > >(*/ Scl X Y) Exactly. The reason is

Re: Scaled division and sqrt

2017-02-27 Thread Lindsay John Lawrence
Hi Danilo, Ah. I get it. Interesting idea. If you are going to use a list, could also just put the 'scale' in a property of the list? When I came across the 'allbase function in Mike Penchkin's code... I thought of the following... It would be a bit wasteful of storage, but could represent

Re: Scaled division and sqrt

2017-02-27 Thread Danilo Kordic
By constructing base 10 floating point numbers with ``[list Significand 'E Exponent]''. As if `E' is a binary operator. Of course that makes no sense in Lisp. ``(Decimal Significand Exponent)'' would make sense. For example: : (sqrt 2) -> (141421356237309505 E -17) -- UNSUBSCRIBE:

Re: Scaled division and sqrt

2017-02-27 Thread Danilo Kordic
I forgot to say: ``As if `E' is an _infix_ binary operator. '' -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Re: Scaled division and sqrt

2017-02-27 Thread Alexander Burger
Hi Lindsay, > Having just tried it... I am surprised that the 'sqrt* I implemented is > quite a bit faster! than the built-in 'sqrt. I'll try the long division > later. Wow, that's indeed a bit surprising. However, it depends on the scale, and I think a can explain (see below). > : (scl

Re: Scaled division and sqrt

2017-02-27 Thread Lindsay John Lawrence
Hi Alex, Erik, I definitely took the 'long way around' on this one... and got some good exercise along the way! =) Thank you for the detailed explanation. I get it now... although I need a bit more practice and care in using the functions comfortably. My initial impetus was to be able to

Scaled division and sqrt

2017-02-27 Thread Lindsay John Lawrence
Hi, Are there scaled (fixed point) versions of division and sqrt in picolisp? I may have missed them... In any event I wrote a couple of functions to provide that functionality that may be useful to others as well. Performance is reasonable. It is quite nice to be able to be able to do

Re: Scaled division and sqrt

2017-02-27 Thread Joh-Tob Schäg
Now there are before there were not. Am 27.02.2017 10:07 schrieb "Lindsay John Lawrence" < lawrence.lindsayj...@gmail.com>: > Hi, > > Are there scaled (fixed point) versions of division and sqrt in picolisp? > I may have missed them.. > > In any event I wrote a couple of functions to provide that