Ok.  I was operating under the assumption that a float is a float is a
float so we didn't need to worry about it.  What would go wrong if we
didn't do the sprintf and stored 2.1E-6 in the db?


On Tue, Jun 25, 2013 at 1:23 PM, Shad Laws <notifications@github.com> wrote:

> In modules/gallery/classes/Gallery/Model/Item.php:
>
> > @@ -27,7 +27,7 @@ public function __construct($id=null) {
> >      if (!$this->loaded()) {
> >        // Set reasonable defaults
> >        $this->created = time();
> > -      $this->rand_key = Random::percent();
> > +      $this->rand_key = sprintf("%f", Random::percent());  // sprintf to prevent things like 2.1E-6
>
> Hmm, I'm not sure if I'm a big fan, as it limits us to 100k discrete
> numbers. For example, in my personal gallery of 35k pics, it's pretty
> likely I'll have a collision or two, so certain photos will (literally)
> never appear in random queries.
>
> Another option: we can just put in a floor, so the numbers have to be
> between 0.0001 < x < 1...
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/gallery/gallery3/pull/430/files#r4876584>
> .
>