Dicom.Data.DcmDataset.GetFloat C# (CSharp) Method

GetFloat() public method

public GetFloat ( Dicom.Data.DicomTag tag, float deflt ) : float
tag Dicom.Data.DicomTag
deflt float
return float
        public float GetFloat(DicomTag tag, float deflt)
        {
            DcmElement elem = GetElement(tag);
            if (elem != null && elem.Length > 0) {
                if (elem.VR == DicomVR.FL)
                    return (elem as DcmFloatingPointSingle).GetValue();
                else if (elem.VR == DicomVR.DS)
                    return (elem as DcmDecimalString).GetFloat();
                else if (elem.VR == DicomVR.OB || elem.VR == DicomVR.UN) {
                    var bytes = elem.ByteBuffer.ToBytes();
                    return BitConverter.ToSingle(bytes, 0);
                } else
                    throw new DicomDataException("Tried to access element " + tag.ToString() + " with incorrect VR");
            }
            return deflt;
        }