anybody know how i would go about converting floats

i have a float of 0 to 512 and i need to convert that into 0 to 1, so 0.5 would equal 256 and so on

You just need to normalize it!

The max amount of value divided by itself is 1

512/512 = 1

Half of the value divided by the total is 0.5

256 / 512 - 0.5

To get your original value again just multiply by the max amount

0,5 * 512