Skip to content
⌘ NSIS Forum Archive

Intop strange result

8 posts

mrbean87#

Intop strange result

What's wrong with intop?

strcpy $0 007
intop $0 $0 + 1
messagebox mb_ok $0

returns correctly 8

strcpy $0 008
intop $0 $0 + 1
messagebox mb_ok $0

returns incorrectly 1, when I should expect 9
deguix#
If you attach a "0" before the number, it is going to be an octal number (a numbering system based on using digits 0-7). If you want to calculate using the decimal system, you have to remove the extra 0's before the number.

You can also use Math plug-in for calculations, but it doesn't support octal numbers (comes with NSIS).
mrbean87#
this happens only if I attach 2 zero... If I use only one zero, it uses the decimal system?
deguix#
Yeah, it has to have 2 0's before the number, which contradicts with the octal numbers definition in the docs in which those are "numbers beginning with a 0 and no x". But at the same time, the number 008 does not exist (like 009), and it is considered 0 because it is not valid.

Remember that IntOp always returns the result as a decimal number, so 007+001=8.
deguix#
Yeah, it has to have 2 0's before the number, which contradicts with the octal numbers definition in the docs in which those are "numbers beginning with a 0 and no x".
Actually, it only needs 2 0's for numbers 0-7, because 010 = 8 (correct).
kichik#
You don't really need two zeros. You just need the first digit after the zero to be in a valid range. That is, it must be larger or equal to 0 and smaller or equal to 7. If it's not in that range, it'll fall back to decimal.
mrbean87#
So, the number 008 is considered in octal notation, because the first number after the initial zero is another 0 (which is in the correct "range"), but when it checks the entire number, it finds an invalid number (008) and replaces it with a 0. Am I right?