9
9

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 2012-12-27

いつも忘れてしまうので。
サンプルコードがObj-Cという理由でタグはObjCにしています。

よくわかるまとめ

フォーマット指定子一覧

先頭に0を足して桁数を揃える(0詰め)

NSLog(@"%03d, %04d, %05d", 5, 10, 100);
/*
005, 0010, 00100
*/

任意の小数点以下を切り捨てて揃える

NSLog(@"%.1f, %.2f, %.3f", 0.123, 0.123, 0.123);
/*
0.1, 0.12, 0.123
*/
9
9
0

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
9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?