# Float16 v CGFloat + Mirror

**URL:** <https://forums.swift.org/t/float16-v-cgfloat-mirror/77297>\
**Category:** Using Swift\
**Tags:** mirror, cgfloat, float16\
**Created:** [January 19, 2025, 4:15pm UTC](https://forums.swift.org/t/float16-v-cgfloat-mirror/77297 "2025-01-19T16:15:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [January 19, 2025, 4:15pm UTC](https://forums.swift.org/t/float16-v-cgfloat-mirror/77297/1 "2025-01-19T16:15:13Z")

</div>

Both `Float16` and `CGFloat` are "struct".  
Why does Mirror API treat them differently?

```swift
func printMirror<T>(_ v: T) {
    let mirror = Mirror(reflecting: v)
    print("\ndisplayStyle: \(String(describing: mirror.displayStyle))")
    print("subjectType: \(String(describing: mirror.subjectType))")
    print("children count: \(mirror.children.count)")
    mirror.children.forEach { child in
        print(" \(String(describing: child.label)) \(child.value)")
    }
}

```

```
printMirror(Float16(0))

```

> displayStyle: Optional(Swift.Mirror.DisplayStyle.struct)  
> subjectType: Float16  
> children count: 1  
> Optional("\_value") (Opaque Value)

```
printMirror(CGFloat(0))

```

> displayStyle: nil  
> subjectType: Double  
> children count: 0

---

<div class="post-metadata">

**Author:** ![mattcurtis](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/mattcurtis/32/18493_2.png) [@mattcurtis](https://forums.swift.org/u/mattcurtis)\
**Post date:** [January 20, 2025, 12:09am UTC](https://forums.swift.org/t/float16-v-cgfloat-mirror/77297/2 "2025-01-20T00:09:53Z")

</div>

`CGFloat` is _bridged_ to Swift as a struct, but it's not a _native_ Swift type. `CGFloat` is originally defined by the Core Graphics framework as an alias for C value primitives (either `float` or `double`, depending.)

`Float16` on the other hand is a _native_ Swift type and Swift is free to define it as it sees fit, so long as it does what it's supposed to (store a 16 bit float value.) In this case that [Swift has chosen to implement it](https://github.com/swiftlang/swift/blob/main/stdlib/public/core/FloatingPointTypes.swift.gyb#L79) (and probs other number types) as a struct with an internal `_value` property.
