티스토리 뷰
유용한 수학 함수
ceil() – 올림
ceil(1.2) : 2.00
ceil(1.7) : 2.00
ceil(-1.2) : -1.00
ceil(-1.8) : -1.00
floor() – 버림
floor(1.2) : 1.00
floor(1.8) : 1.00
floor(-1.2) : -2.00
floor(-1.8) : -2.00
round() - 반올림
round(1.2) : 1.00
round(1.7) : 2.00
fabs() – 절대값
fabs(1.2) : 1.20
fabs(1.8) : 1.80
fabs(-1.2) : -1.20
fabs(-1.8) : -1.80
sqrt() - 루트
sqrt(4) : 2.00
pow(x, y) - 거듭제곱근
pow(2, 10) : 1024.00
exp() – 지수값
exp(1) : 2.72
유용한 Define 값
#define M_E 2.71828182845904523536028747135266250 /* e */
#define M_LOG2E 1.44269504088896340735992468100189214 /* log 2e */
#define M_LOG10E 0.434294481903251827651128918916605082 /* log 10e */
#define M_LN2 0.693147180559945309417232121458176568 /* log e2 */
#define M_LN10 2.30258509299404568401799145468436421 /* log e10 */
#define M_PI 3.14159265358979323846264338327950288 /* pi */
#define M_PI_2 1.57079632679489661923132169163975144 /* pi/2 */
#define M_PI_4 0.785398163397448309615660845819875721 /* pi/4 */
#define M_1_PI 0.318309886183790671537767526745028724 /* 1/pi */
#define M_2_PI 0.636619772367581343075535053490057448 /* 2/pi */
#define M_2_SQRTPI 1.12837916709551257389615890312154517 /* 2/sqrt(pi) */
#define M_SQRT2 1.41421356237309504880168872420969808 /* sqrt(2) */
#define M_SQRT1_2 0.707106781186547524400844362104849039 /* 1/sqrt(2) */
Math.h 파일에서 더 많은 정보가 있음.
'Mobile > iOS' 카테고리의 다른 글
[iOS/Objective-C] __weak, __block (0) | 2017.12.29 |
---|---|
[iOS/swift] Objective-C 와 swift를 함께 사용하기 (0) | 2017.12.22 |
[iOS/cocoapods] cocoapods 사용하기 (0) | 2017.12.09 |
[iOS/swift] enum multiple value use (0) | 2017.12.01 |
[iOS] fatal error: malformed or corrupted AST file 해결 (0) | 2017.11.27 |
- Total
- Today
- Yesterday
- Codable
- ubuntu
- Xcode
- tomcat
- intellij
- go
- CentOS
- Windows
- golang
- github
- MySQL
- nodejs
- Spring
- war
- git
- Linux
- Python
- android
- Gradle
- cocoapods
- Kotlin
- windows10
- Java
- enum
- docker
- ios
- php
- rxswift
- centos8
- SWIFT
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |