Updated float packing function to handle multiple formats