<!--
{
  "availability" : [
    "DriverKit: -",
    "iOS: -",
    "iPadOS: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "DriverKit",
  "identifier" : "/documentation/DriverKit/OSNumber/withNumber-2c6oe",
  "metadataVersion" : "0.1.0",
  "role" : "Static Method",
  "symbol" : {
    "kind" : "Static Method",
    "modules" : [
      "DriverKit"
    ],
    "preciseIdentifier" : "c:@S@OSNumber@F@withNumber#*1C#l#S"
  },
  "title" : "withNumber"
}
-->

# withNumber

Allocates an OSNumber object with value from a c-string and size.

```
static OSNumberPtr withNumber(const char *valueString, size_t numberOfBits);
```

## Parameters

`valueString`

A c-string which will be parsed with strtoll(,,0).

`numberOfBits`

Size of the value. Only 8, 16, 32, or 64 are valid sizes.

## Return Value

NULL on failure, otherwise the allocated OSNumber with reference count 1 to be released by the caller.

## Discussion

Allocates an OSNumber object with value from a c-string and size.

---

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)