Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- IEEE 754



  Why 0.1+0.2 != 0.3

In programming languages such as JavaScript, c/c++, Java and Matlab, you will find that you will get unexpected result when doing float point calculation. For example, when calculating 0.1 + 0.1, you will not get 0.3: > 0.1 + 0.2 == 0.3 false > 0.1 + 0.2 0.30000000000000004 Don't be surprised of this result, this is the end result of IEEE 754 standard, float point number cannot be accurately represented according to IEEE 754 because: No enough memory is allocated for representing the num...

   float point,comparison,JavaScript     2014-11-19 05:32:46

  Accurate floating point number calculation in JavaScript

In JavaScript, since floating point is defined with IEEE754,there will be some accuracy issues while doing floating point number arithmetic. Here is a function which can resolve the accuracy issue. var calc = function(num1,operator,num2,len){    var numFixs = function(num){        var arr = num.toFixed(len).toString().split('.');        return parseInt(arr.join(''));    }    switch(operator){...

   JavaScript, floating point,IEEE 754,accuracy     2012-12-27 11:07:49

  Why cannot compare double values directly for equality?

A question in PHP: Get some value from the database and use floatval() to convert it to floatint point value, then compare it with another value which is also converted to floating point value with floatval(). These two values are the same when using var_dump() to output, the two outputs are float(8.87), they are the same. But when comparing them for equality, the result is weird., they are not equal. Why?To analyze this question, we need to start with PHP data types. PHP uses weak types. In PHP...

   PHP,floating, precision,compare,equality     2012-06-27 09:01:36

  JavaScript's Two Zeros

JavaScript has two zeros: -0 and +0. This post explains why that is and where it matters in practice. The signed zero Numbers always need to be encoded to be stored digitally. Why do some encodings have two zeros? As an example, let’s look at encoding integers as 4-digit binary numbers, via the sign-and-magnitude method. There, one uses one bit for the sign (0 if positive, 1 if negative) and the remaining bits for the magnitude (absolute value). Therefore, -2 and +2 are encoded as f...

   JavaScript,zeros     2012-03-24 05:21:49

  Bug caused by using changeable value as the default in "python method overload"​

In python we can set the passed in parameter's default value to make the function has the same running feature as the method overload in Java. Define a function like this: def testFunction(self, param1, param2=None, param3=None): Normally we use "None" as the parameter's default value. We can also use str/bool as the default value, but is it OK we use empty list [] as its default value? This is our test program: """ A test program using empty list as the passed-in parameter's default value. ...

   PYTHON     2019-03-11 08:52:52

  Key challenges in Agile implementations

7Share6inShareAgile methodology was supposed to be a solution to solve all of our problems. But it looks like it’s not. Some issues appear when companies start to implement Agile in their organizations. A research has been done on seventeen companies using Agile methodology (People over processes: Key people challenges in Agile Development). Authors chose nine of the most often reported issues. I’d like to focus on four, in my opinion, most important. #1 Developer...

   Agile development,Chanllenge,Communication,Business     2011-11-30 02:55:04

  A Guide on Creating a Magento 2 Extension

Normal 0 false false false EN-US X-NONE X-NONE

   MAGENTO, MAGENTO 2,MAGENTO 2 MODULE CREATOR     2016-02-29 03:08:08

  A re-introduction to JavaScript

Introduction Why a re-introduction? Because JavaScript has a reasonable claim to being the world's most misunderstood programming language. While often derided as a toy, beneath its deceptive simplicity lie some powerful language features. 2005 saw the launch of a number of high-profile JavaScript applications, showing that deeper knowledge of this technology is an important skill for any web developer. It's useful to start with an idea of the language's history. JavaScript was created in 1...

   JavaScript,Types,Array,Re-introduction,OOP     2012-02-09 05:38:08

  Rediscovering the RSync Algorithm

A:Ok, you’re synchronizing this over the web; and what do you use for the synchronization? B: Oh, we implemented the rsync algorithm. A: uhu. And what do you do with really big files? B: The same. A: And you also synchronise folders? B: Yes. A: And how do you do that? B: we iterate over the folder, using the algorithm on every file, recursing over subfolders. A: Can you try 2 things for me? First, a very large file; and second, a large codebase, and see if it holds. Introduction First ...

   ReSync algorithm,Discovery     2012-02-14 10:47:24

  Comparing Floating Point Numbers, 2012 Edition

We’ve finally reached the point in this series that I’ve been waiting for. In this post I am going to share the most crucial piece of floating-point math knowledge that I have. Here it is:[Floating-point] math is hard.You just won’t believe how vastly, hugely, mind-bogglingly hard it is. I mean, you may think it’s difficult to calculate when trains from Chicago and Los Angeles will collide, but that’s just peanuts to floating-point math.Seriously. Each ti...

   Floating point number,Comparison,True value     2012-02-23 07:11:03