Originally Posted by romesaz
hey, I know there's at least a few software developers here, so I thought i'd ask.
How can you type cast in Python?
mainly, casting a string to a float.
and how would you deal with any fractionals?
i.e. given a = '5.5'
just doing int(a) doesn't exactly work well
Unfortunately I don't program in python but I do in alot of other languages.
Usually to typecast something (at least in C style) would be as follows literally.
The problem you are facing here is trying to put a string into a data type. I know in java there's string classes to change stings to a data type.
double tempPrice = Double.parseDouble(priceString);
With strings to data types it's tricky because you might end up trying to squeeze a 64bit(maybe a double) number to a 32bit data type.
If you are dealing with fractionals, I would use long or double data type.
Sorry I don't know python but at least I might've helped with the logic to it lol