News for hackers. Stuff that matters.
Re:Lua 5.3: integers, bitwise operators, and a basic UTF-8 l... by jws on Monday January 12, 2015 @01:09PM (#8875412)
and integers 2^53 and less can be store exactly as a (64-bit) float anyway.

Until you divide them by three.

There is a time and a place for integer arithmetic. You could get there with liberal use of truncation, but it reads better as native integer arithmetic.

The slope is slippery, time to resist or embrace native complex, rationals, and quaternions… I only stop the list here because it is as much as I've ever used in real world code.

Re:Lua 5.3: integers, bitwise operators, and a basic UTF-8 l... by swift on Monday January 12, 2015 @08:44PM (#8877650)
I wonder's what's been used in real world code more, quaternions or Peano naturals. =)
Re:Lua 5.3: integers, bitwise operators, and a basic UTF-8 l... by JadeNB on Monday January 12, 2015 @08:43PM (#8877647)
When did you use quaternions? (Genuinely curious!)
Re:Lua 5.3: integers, bitwise operators, and a basic UTF-8 l... by jws on Monday January 12, 2015 @10:40PM (#8878002)
Minecraft-like game I wrote with my daughter. I discovered their use the hard way after having suffered through without them. Any time you are freely rotating a viewpoint or an object in 3D space, you will probably want quaternions.

Do write some good test cases though that compare to someone else's implementation. I accidentally wrote my multiplication backwards and didn't catch it for a long time. I just had a vague feeling that something was wrong every time I wrote rotation code.

Re:Lua 5.3: integers, bitwise operators, and a basic UTF-8 l... by kephra on Tuesday January 13, 2015 @08:06AM (#8879493)
Quarternions are much easier then the typical vector arithmetic, that is used by OpenGL ES.

Linden Scripting Language even provides quarternions conversion with llEuler2Rot, llRot2Euler and llAxisAngle2Rot. See: http://wiki.secondlife.com/wiki/Quaternion for an introduction.

So quaternions are useful for 3d games, and games are a hot topic for Lua. But its not required, that complex numbers or quarternions are part of base language. See: http://lua-users.org/wiki/ComplexNumbers - thats easy to implement with Lua prototyping.

Re:Lua 5.3: integers, bitwise operators, and a basic UTF-8 l... by dottrap on Monday January 12, 2015 @09:13PM (#8877728)
Quaternions are pretty common in 3D graphics.