Division principle in TCL or PERL ? Correct!!

Posted by udayas on 2013-12-30 22:17
Forums: TDK discussion | OS: All / Any

The result of -63/5 is -13 in TCL (and also in PERL).

But when I am going to system calculator or Java or C# or Google calculator I get -12.

I get the logic of -13 here as -63>-65

so surprisingly who is wrong here??

grahams
ActiveState Staff
Thu, 2014-01-02 09:11

The difference is in which math library they call.

Java, Google, and C# are using the MicroSoft C# floating point math library.

Tcl and Perl are using a C floating point math library.

Both libraries follow their respective standards, so both are correct. You may disagree with the way the standards have been defined, but that is one of the differences of C vs C#.