import struct


def read_float(stream, size):
	"""
	
	Reads an encoded floating point value from a file-like object.
	
	:arg stream: the file-like object
	:arg size: the number of bytes to read and decode (must be 0, 4, or 8)
	:type size: int
	:returns: the decoded floating point value
	:rtype: float
	
	"""
	
	if size not in (0, 4, 8):
		raise IOError('Cannot read floating point values with lengths other than 0, 4, or 8 bytes.')
	value = 0.0
	if size in (4, 8):
		data = stream.read(size)
		value = struct.unpack({
			4: '>f',
			8: '>d'
		}[size], data)[0]
	return value