How do I convert a padded string to an integer while preserving padding?

Applying idea of padding to integers is meaningless. If you want to print/represent them you need strings, integers just don't have padding.

Ohhhh that's where I'm wrong. Integers don't have padding. I must've missed that tidbit somewhere.

Thank you! – Jack Tranner Jul 12 '10 at 21:08.

Integers don't have a concept of padding, but if you want then you can store both the value and the original length instead of just the value: int_list = (int(x), len(x)) for x in list_padded Then if you want to reconstruct the original data you have enough information to do so. You may even want to make a custom class to store both these fields instead of using a tuple.

Since the INT type is a number it will be stored without leading zeros. Why would you want to store 675 as 00675? That's meaningless in the realm of integers.

I would suggest storing the integers as integers and then only apply the padding when you access them and print them out (or whatever you are doing with them).

Leading zeros is just for data representation: "{0:b}". Format(4). Zfill(8) You can change XOR with other bit-wise operations: def xor(x, y): return (~x & y) | (~y & x) def bool_xor(x, y): return ((not x) and y) or ((not y) and x) Actually, you can express all bitwise operations with just one logical operation: en.wikipedia.org/wiki/Functional_complet....

But now I need to turn that padded string to a padded integer. But what I get is a list of integers sans the padding. Appreciate any direction or suggestions.

I'm working through a basic encryption exercise in a book. It has given me a list of pseduocode to work through - get cipher string 1-127 and a message, convert both to binary, strip off the 0b, and pad with zeroes. However it wants me to do the rest WITHOUT XOR!

I've love to use the XOR operation but I'm afraid doing so I'm not going to learn what I need to.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions