Help us understand the problem. What is going on with this article?

# Swiftの16進数小数の指数のポイント

More than 3 years have passed since last update.

Swiftの16進数小数で、勘違いしていた部分があったのでまとめを書きました。

# Swiftの16進数小数は必ず指数部分を付けないといけない

```let a = 0x1.0p0 //OK
let b = 0x1.0 //NG
let c = 0x1 //OK 整数は指数が必要ではない
```

# 指数表記はpで始める

```let a = 0x1.0p0 //OK
let b = 0x1.0e0 //NG
let c = 1.0e0 //OK 10進の場合はe
```

# 指数表記は10進数で表記する

```let a = 0x1.0p10 //OK
let b = 0x1.0pa //NG
```

# 小数点移動は2進数状態で行われる（ここが盲点）

```let a = 0x1.0p1
let b = 0x10.0p0 //10進数で16
let c = 0x2.0p0 //10進数で2
a == b //false
a == c //true
```

アウトドアプログラミング初心者 コンパイルエラー寄せ集め https://samekard.blogspot.jp/2014/09/swifterror.html
https://samekard.jp/ja/index.html
Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away