Hmm...
I tried this out as JavaScript so I could open the browser Dev tools (F12) and run it in the console:
var rez = 0; var broj = 1123583145;
while (broj > 0){
cif = broj %10;
rez = (cif & 1) ? Math.trunc(rez * 10 + cif) : rez;
console.log("rez : " + rez);
broj = broj /10;
console.log("broj : "+ broj)
}
console.log(rez);
If you open the Browser console window (F12 in most browsers and paste and run that code you'll see that it shows you how you get the value.
Basically I added output each time through the loop so you can see the values of broj and
rez
each time.
Also, do you understand the line I marked // uses ternary operator?
rez = (cif & 1) ? Math.trunc(rez * 10 + cif) : rez;
That line does a bitwise operation on the value of cif and 1.
The first time through cif = 5; (1123583145 % 5) // 1123583145 mod 5
since cif = 5 then binary value is 0101
The & is bitwise and so the (cif & 1) will
0101
0001
----
0001
The value of cif & 1 = 1
Since 1 evaluates to true then the left side of the ternary operator is completed:
Math.trunc(rez * 10 + cif) // trunc function is to insure it is an integer value
rez * 10 = 0 // since rez starts out at 0
0 + 5 (value of cif) means that rez gets set to 5
Below are the first N times through the loop, where you can see what is happening.
You can see it is taking each digit of the initial value and building it up.
I leave the rest to you to examine.
rez : 5
broj : 112358314.5
rez : 5
broj : 11235831.45
rez : 51
broj : 1123583.145
rez : 513
broj : 112358.31450000001
rez : 513
broj : 11235.831450000001
rez : 5135
broj : 1123.583145
rez : 51353
broj : 112.3583145
rez : 51353
broj : 11.235831450000001
rez : 513531
broj : 1.123583145
rez : 5135311
broj : 0.1123583145
broj : 0.01123583145
broj : 0.0011235831450000001