-4

Can someone explain the meaning of this line of code?

i  = * ( long * ) &y; 

The code is from wikipedia, Fast inverse square root. Is there a way to do the same with python?

MIbrah
  • 1,007
  • 1
  • 9
  • 17
SeF
  • 3,864
  • 2
  • 28
  • 41
  • 2
    `&y` is casted to a `long*` pointer and dereferenced. The result is stored in `i`. I doub't to do such is possible in python. – πάντα ῥεῖ Mar 31 '16 at 14:00
  • You could possibly achieve the same using the [`struct` module](https://docs.python.org/3.5/library/struct.html): `i = struct.unpack('l', struct.pack('f', y))`, but the actual line relies on how the values are represented in memory - which isn't something you can easily get at with python. – RoadieRich Mar 31 '16 at 14:33

1 Answers1

0

In Python why not just do x**-1/2 or x**-.5

KR29
  • 393
  • 1
  • 4
  • 19