lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Philipp Janda schrieb:
Am 20.09.2010 16:12, schrieb bb:
JavaScript-C 1.8.0 pre-release 1 2009-02-16 : -7%-9 = -7, 9%-7 = 2, 7%-9
= 7

Ch Standard edition, version 6.3.0.14091:  -7%-9 = -7, 9%-7 = 2, 7%-9 = 7

java version "1.6.0_0" OpenJDK  Runtime Environment (build 1.6.0_0-b11):
-7%-9 = -7, 9%-7 = 2, 7%-9 = 7

Python 2.5.2 (r252:60911, Jan 24 2010, 14:53:14) [GCC 4.3.2] on linux2 :
-7%-9 = -2, 9%-7 = -5, 7%-9 = -2

Lua 5.1.3 : -7%-9 = -2, 9%-7 = -5, 7%-9 = -2

[...]

May be a Lua-code for a function for a c-like handling of the %-operator
might be useful? So the user might have "religious freedom".

That's what math.fmod is for:

Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
= -7%-9, 9%-7, 7%-9
-7      -5      -2
= math.fmod(-7,-9), math.fmod(9,-7), math.fmod(7,-9)
-7      2       7


Regards BB


Philipp




Many thnx for the eye opener!

Reagrds BB