# [PD] vanilla solution for random float

Raphaël Ilias phae.ilias at gmail.com
Tue May 31 17:06:41 CEST 2016

```Sorry my error, I tried :

random 1e+08 / 1e+08

..and it works. Don't know how I got this wrong results.
It evens work until 1e+09, the precision error (that outputs 0) starts from
1e+10.

Is 1e+09 using the full decimal precision of pd's 32-bits floats ?

thanks

Raphaël

2016-05-31 17:00 GMT+02:00 Miller Puckette <msp at ucsd.edu>:

> I just tried "random 1e8" and "/ 1e8" and it seems to work for me.  If it
> doens't for you that's a bug I should look at :)
>
> cheers
> Miller
>
> On Tue, May 31, 2016 at 04:48:59PM +0200, apvague at gmail.com wrote:
> >
> >
> > Sent from my iPhone
> >
> > > On May 31, 2016, at 4:44 PM, Raphaël Ilias <phae.ilias at gmail.com>
> wrote:
> > >
> > > Hello list,
> > >
> > > I want to do a simple task : pick a random float in a defined range
> (let's say between 0.0 and 1.0).
> > > I know there are this kind of objects in external libraries (something
> like [randomF] if remember), but since the collapse of Pd-Extended, I
> generally prefer to make vanilla abstractions.
> > >
> > > The two solutions i foresee are :
> > >
> > > solution #1 :
> > >
> > > [random 1e+06]
> > >  |
> > > [/ 1e+06]
> > >
> > > but this way, it doesn't use the full floating-point resolution ?...
> and going over that range (like 1e_07) will result in errors (outputs 0) I
> guess because of floating-point complexity.
> > >
> > >
> > > # solution #2 :
> > >
> > > [noise~]
> > >   |
> > > [snapshot~]
> > >
> > > but this won't work if DSP/audio is turned off.
> > >
> > >
> > >
> > > so I wondered if there are other vanilla and efficient solutions?
> > > ...or if I just have to get the external from deken... ?
> > > :)
> > >
> > > thanks,
> > >
> > > Raphaël
> > > _______________________________________________
> > > Pd-list at lists.iem.at mailing list
> > > UNSUBSCRIBE and account-management ->
> https://lists.puredata.info/listinfo/pd-list
> >
> > _______________________________________________
> > Pd-list at lists.iem.at mailing list
> > UNSUBSCRIBE and account-management ->
> https://lists.puredata.info/listinfo/pd-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20160531/f387aa51/attachment.html>
```