A couple:
1. 2 is a number, whereas "2" is a character string; most languages will either convert the number into a string ("2" + "2" = "22") or else convert the string into a number (2 + "2" = 4); this language converted the string into a number (2 + "2" = 4) and then converted the result back into a string (2 + "2" = "4")
2. [] is usually an empty array (list of stuff); "2" + [] usually either produces a type error (can't add a character string to an array - they're not the same sort of thing), or else the empty array gets converted to a "" so "2" + [] = "2", or else the "2" gets put into the array so "2" + [] = ["2"]. This language put "2" in the array but then converted the entire thing to a character string, so "2" + [] = "[2]"
3. This is normal behavior - if you divide by zero then you usually get an error or else you get a NaN (not a number)
4. Dunno what's going on here - maybe NaP means Not a Parenthesis?
5. Normal behavior
6. Dunno
7. Dunno
8. 3/2 + 1/2 is going to produce roundoff error because computers can't precisely represent a lot of decimal values unless you take special care about how you store them. The joke here is that 2/(2 - (3/2 + 1/2)) would result in 2/0 using precise arithmetic, but using imprecise arithmetic the (3/2 + 1/2) isn't going to equal 2, so what the language did is it precisely calculated the result of 2/(2 - (3/2 + 1/2)) which is 2/0 which is NaN, then it appended the roundoff error from (3/2 + 1/2).
9, 10, 11, 14(???). Dunno
13. The Floor function takes a decimal as input and returns the next lowest integer as output, so Floor(10.5) should return 10. Looks like here it just prints 10.5 on the floor.
1. 2 is a number, whereas "2" is a character string; most languages will either convert the number into a string ("2" + "2" = "22") or else convert the string into a number (2 + "2" = 4); this language converted the string into a number (2 + "2" = 4) and then converted the result back into a string (2 + "2" = "4")
2. [] is usually an empty array (list of stuff); "2" + [] usually either produces a type error (can't add a character string to an array - they're not the same sort of thing), or else the empty array gets converted to a "" so "2" + [] = "2", or else the "2" gets put into the array so "2" + [] = ["2"]. This language put "2" in the array but then converted the entire thing to a character string, so "2" + [] = "[2]"
3. This is normal behavior - if you divide by zero then you usually get an error or else you get a NaN (not a number)
4. Dunno what's going on here - maybe NaP means Not a Parenthesis?
5. Normal behavior
6. Dunno
7. Dunno
8. 3/2 + 1/2 is going to produce roundoff error because computers can't precisely represent a lot of decimal values unless you take special care about how you store them. The joke here is that 2/(2 - (3/2 + 1/2)) would result in 2/0 using precise arithmetic, but using imprecise arithmetic the (3/2 + 1/2) isn't going to equal 2, so what the language did is it precisely calculated the result of 2/(2 - (3/2 + 1/2)) which is 2/0 which is NaN, then it appended the roundoff error from (3/2 + 1/2).
9, 10, 11, 14(???). Dunno
13. The Floor function takes a decimal as input and returns the next lowest integer as output, so Floor(10.5) should return 10. Looks like here it just prints 10.5 on the floor.
Comment