---
title: "logicalValue(asTypeTruncatingIfNeeded:)"
framework: corehid
role: symbol
role_heading: Instance Method
path: "corehid/hidelement/value/logicalvalue(astypetruncatingifneeded:)"
---

# logicalValue(asTypeTruncatingIfNeeded:)

The raw value of the data cast as an integer type and bound by the HIDElement’s logical minimum and logical maximum values.

## Declaration

```swift
func logicalValue<IntegerType>(asTypeTruncatingIfNeeded: IntegerType.Type) -> IntegerType? where IntegerType : FixedWidthInteger
```

## Parameters

- `asTypeTruncatingIfNeeded`: The type to which to cast the underlying bytes before applying bounds, truncating or extending the bytes as necessary.

## Return Value

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

## Discussion

Discussion If the raw value is out of bounds, this returns nil. For example, if the logical minimum and logical maximum are specified as 1 and 127 respectively, and the raw value is 0, the logical value is undefined.

## See Also

### Get element data and values

- [bytes](corehid/hidelement/value/bytes.md)
- [integerValue(asTypeTruncatingIfNeeded:)](corehid/hidelement/value/integervalue(astypetruncatingifneeded:).md)
- [physicalValue(fromTypeTruncatingIfNeeded:as:)](corehid/hidelement/value/physicalvalue(fromtypetruncatingifneeded:as:).md)
- [timestamp](corehid/hidelement/value/timestamp.md)
