bin2d function.