Re: puzzling code

new topic     » goto parent     » topic index » view thread      » older message » newer message

> Hi, All.
>
> While studying Matt Arriola's Crypt.ex code (Recent User Contibutions),
> I found a line of code which I'm at a loss to understand.
> Simulated code follows;
>
> -- begin code
>
> with trace
> sequence bits
> object dummy
> trace(1)
>
> bits = "11000111001111000011100110101011"
>
> bits -= '0'    <--- what's this doing???
>
> dummy = 21      -- has no meaning ... here just for the trace
> -- end code
>
> if you run the above which trace on,  and watch the display of
> variables under the trace window, you'll see how the line
> "bits -= '0' transforms the sequence bits. Can somebody explain
> what's happening ?
>
> Appreciate any help.
it's subtracting the the value of '0'(48) from the `bits` sequence, making
each element the actual numeric value of number that is represented.
In short, it's a quick and crude form of value()

Chris

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu