dseguy, French
@dseguy@phpc.social avatar

doesn't allow float as index in arrays.

It is possible to use them as such by casting them to string. Later, type juggling will allow adding to another float, seamlessly.

https://php-tips.readthedocs.io/en/latest/tips/store_float_as_index.html

mitelg,
@mitelg@phpc.social avatar

@dseguy works "seamlessly"? I guess, it will also lose information due to the float precision issues in some cases 😬

dseguy,
@dseguy@phpc.social avatar

@mitelg mea culpa, it was seamless in the case I was working on.

With a finite float, it works.

With calculated float, there are possible hidden decimals : https://3v4l.org/dJ0mP;

It will loose precision with the default 'precision' (the directive), but not with higher levels (due to truncation).

michael,
@michael@thms.uk avatar
  • All
  • Subscribed
  • Moderated
  • Favorites
  • php
  • DreamBathrooms
  • magazineikmin
  • thenastyranch
  • Youngstown
  • Durango
  • rosin
  • slotface
  • vwfavf
  • InstantRegret
  • PowerRangers
  • kavyap
  • tsrsr
  • everett
  • mdbf
  • normalnudes
  • hgfsjryuu7
  • GTA5RPClips
  • ethstaker
  • tacticalgear
  • ngwrru68w68
  • cubers
  • khanakhh
  • osvaldo12
  • tester
  • modclub
  • cisconetworking
  • Leos
  • anitta
  • All magazines