Value types, like integers, Bits, Real, are being passed by value (Meaning, their value is being passed to the function, and not the pointer to the value) when used in a function-in.
So any attempt to change their value within a function code will only affect the value inside the function.
Arrays and structs are being passed by Reference, so if you change a value of a bit or a number inside it from a function code, then it will affect the value outside the function.
You have 2 options: Passing an array/ struct, or pass the number / bit as a function-out (which means that it will be passed as a reference).
I hope this information helps.