---
title: "physicalValue(fromTypeTruncatingIfNeeded:as:)"
framework: corehid
role: symbol
role_heading: Instance Method
path: "corehid/hidelement/value/physicalvalue(fromtypetruncatingifneeded:as:)"
---

# physicalValue(fromTypeTruncatingIfNeeded:as:)

The logical value of the data, shifted and scaled by the HIDElement’s physical minimum, physical maximum and exponent.

## Declaration

```swift
func physicalValue<IntegerType, FloatingType>(fromTypeTruncatingIfNeeded: IntegerType.Type, as: FloatingType.Type) -> FloatingType? where IntegerType : FixedWidthInteger, FloatingType : BinaryFloatingPoint
```

## Parameters

- `fromTypeTruncatingIfNeeded`: The type to cast the underlying bytes to before bounding, shifting and scaling; truncating or extending the bytes as necessary.
- `as`: The type to cast the calculated floating point result to before returning.

## Return Value

Return Value The calculated value cast as the requested type, or nil if out of bounds.

## Discussion

Discussion The logicalValue(asTypeTruncatingIfNeeded:) is first retrieved with the specified type. If the logical value is undefined, such as when the raw value is out of bounds, the physical value is also undefined. More information and example calculations for physical values can be found in the HID specification: See the HID specification for more details: https://www.usb.org/hid.

## See Also

### Get element data and values

- [bytes](corehid/hidelement/value/bytes.md)
- [integerValue(asTypeTruncatingIfNeeded:)](corehid/hidelement/value/integervalue(astypetruncatingifneeded:).md)
- [logicalValue(asTypeTruncatingIfNeeded:)](corehid/hidelement/value/logicalvalue(astypetruncatingifneeded:).md)
- [timestamp](corehid/hidelement/value/timestamp.md)
