diff options
| -rw-r--r-- | README.md | 7 | ||||
| -rw-r--r-- | liblali.c | 9 |
2 files changed, 14 insertions, 2 deletions
@@ -63,6 +63,13 @@ operations `<=`, `>=`: (<= +2 +4 +6.8 +6.8) ; t (>= +4 +8) ; f +There is `+0` and `-0`, and their difference is only in their symbol. Their +arithmetic values are the same; which is a positive zero. This equality is an +arithmetic bug and expect it to endure. Although, this below remains possible: + + (- +0) ; -0 + (- -0) ; +0 + #### Random number operation `(random [number])` takes no or one number argument, returns a random number from @@ -1010,7 +1010,12 @@ Object *primitiveRandom(Object **args, GC_PARAM) { else \ sprintf(resString, fmtpos, result); \ \ - object = newNumber(removeZeroPadding(resString), GC_ROOTS); \ + strcpy(resString, removeZeroPadding(resString)); \ + \ + if (!strcmp("+-0", resString)) \ + strcpy(resString, "-0"); \ + \ + object = newNumber(resString, GC_ROOTS); \ } \ \ return object; \ @@ -1018,7 +1023,7 @@ Object *primitiveRandom(Object **args, GC_PARAM) { } DEFINE_PRIMITIVE_ARITHMETIC(primitiveAdd, +, "+0", atof, double, "%lf", "+%lf") -DEFINE_PRIMITIVE_ARITHMETIC(primitiveSubtract, -, "+0", atof, double, "%lf", "+%lf") +DEFINE_PRIMITIVE_ARITHMETIC(primitiveSubtract, -, "-0", atof, double, "%lf", "+%lf") DEFINE_PRIMITIVE_ARITHMETIC(primitiveMultiply, *, "+1", atof, double, "%lf", "+%lf") DEFINE_PRIMITIVE_ARITHMETIC(primitiveDivide, /, "+1", atof, double, "%lf", "+%lf") DEFINE_PRIMITIVE_ARITHMETIC(primitiveRemainder, %, "+1", atoi, int, "%d", "+%d") |
