# Number input fields plays binary tunes ?

Hello: here is something i accidentally noticed. I want to know :
_If it is made so on purpose ?
_If someone actually knew it ?
_If someone actually use it ?

When you type a value in a Number input field (like in the “transform property” panel), it acts strange if you type a value sarting with 0.
If you type 0.61878, that is fine
Type 01 and it returns 1 : OK
but type,say, 010 and you dont get 10: you get 8.
It surely looks like binary…
But then why does 020 returns 16 ?
Is it hexa ? NO: the console tilts if you try 0c or 02A1…

There must be a reason…

Anyway i found that funny so i share it…
Please excuse me if it is a well known binary/conversion trick !

It’s not binary but octal, the number system with the base 8.

Available digits are 0…7.

Numbers 0…7 as in decimal system, then the usual placement rules apply. So 010 is 1x8+0. 011 is 1x8 + 1. And so on.

The leading 0 is a mark for octals in quite a few common computer languages. But this should not propagate through to the user interface.

Ohohhhh… Thank you inmare !
So you dont think this is meant to be available in the GUI ?
Funny no-one noticed it before…
Or they did i dont know…
Anyway, is that new to 2.45 ?
I ll try on an old version !
EDIT: I ve tried on an old ZanQdo build: it does the same…

Well, the octal system is of no practical use outside of computers (and even when doing techie things it’s use is VERY limited).

So for the users of an art package this should not be visible. If someone stumbles upon this he expects different behaviour, like you did.

I think the program logic behind this input field is fairly simple: Take the string that has been input and transform it to a number, if possible. This transformation function uses the built-in ways for transformation of literals (=representation of values in human-readable format). That is why you can enter octal (like 010) or hexadecimal (like 0x10) values in these input fields and they are handled correctly.

Okok…
That isn’t important at all but i wonder if this feature is here to serve some purpose…
Anyway: thanks for the explanations ! I will sleep feeling less stupid !

Hm, I just tried it. These numeric input fields are quite powerful, they even let you enter a mathematical term. Then it’s quite logical that they can interpret different literals.

Yep: You can even call python elements like math.pi or math.sqrt() !
Good to know !

I wonder if you can use something like: Plane.LocX to copy another object’s location ?

Hm… you can do in Pydrivers.

In “normal” numerical input fields it would not be that useful. First, you don’t have a full blown editor - a small input area for importing the needed libs, calling the appropriate methods to get the object and then work with it is not that comfortable… Second, it would be evaluated once at input time, it would not be dynamic.

generally, a number prefixed by 0, such as 010, signifies that the digits that follow are to read as an octal number.

0b signifies binary
0x is hex (base 16), etc.

Ok… I think this is the end of this nice and informative little thread…
Thank you !
Or does someone want to add anything ?

Could you tell us exactly how? I know, this is rather useless but as I hardly ever use the input field, I have never felt like I need to mess around with it…but this is actually quite interesting (not to say: funny )! Sort of an easter egg, hm?

Well… if you have to enter 3.14 you can input it more precisery by typing directly “math.pi” (without quotation marks)
Try in the location fields of the transform properties window…
Or,say, “math.sqrt(2)” for an EXACT value of the square root of 2…
Or “math.exp(1)” for an EXACT value of “e” (exponential, Euler’s number=2.718…)
Or 74**2 for 7 times 4 at the power of 2
Or even "1/(math.sqrt(2
math.pi))…

You get it ?

By the way : wie geht es dem guten gemuetlichen Oesterreich ?
I used to live there: lovely !

Haha, danke, uns geht es ganz gut…einzig das Fußball Nationalteam bereitet uns ein Jahr vor der EM große Sorgen :rolleyes: (typisch oesterreichisch eben - kleines Problem, große Aufregung ).

Anyway, thanks for the “tutorial”, now it is clear how to use that input-field…really, that’s pretty useless but still interesting to experiment with. Nice find!

Sorry for the football team…
and…“useless” is the word !