<!--
{
  "availability" : [
    "macOS: 15.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreHID",
  "identifier" : "/documentation/CoreHID/HIDElement/Value/physicalValue(fromTypeTruncatingIfNeeded:as:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core HID",
      "CoreHID"
    ],
    "preciseIdentifier" : "s:7CoreHID10HIDElementV5ValueV08physicalD026fromTypeTruncatingIfNeeded2asq_Sgxm_q_mts17FixedWidthIntegerRzSBR_r0_lF"
  },
  "title" : "physicalValue(fromTypeTruncatingIfNeeded:as:)"
}
-->

# physicalValue(fromTypeTruncatingIfNeeded:as:)

The logical value of the data, shifted and scaled by the [`HIDElement`](/documentation/CoreHID/HIDElement)’s physical minimum, physical maximum and exponent.

```
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

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

## Discussion

The [`logicalValue(asTypeTruncatingIfNeeded:)`](/documentation/CoreHID/HIDElement/Value/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).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)