2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

~~の意味について

Last updated at Posted at 2019-06-02

はじめに

本文は他の方のプログラミングを読んでいた際、見かけた~~という謎記法について調べてみたという話です。

具体的に使われていたコード

input = input.split(/\n|\s/).map(v => ~~v)

"~"について

読み方

読み方はチルダ

意味

javascriptの場合、意味は「ビット反転演算子」

ビット反転演算子って?

オペランドの各ビットを反転します。

~~はどういう意味なのか?

Math.floorの代用

ちなみにMath​.floor()とは?

引数として与えた数以下の最大の整数を返します。
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Math/floor

参考

2
0
6

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?