본문 바로가기

Programming

C++ Math - sqrt (square root, 제곱근, 루트). stl, math.h, 씨쁠쁠, example code, 예제코드

C++ Math - sqrt (squareRoot, 제곱근)C++ Math - sqrt (squareRoot, 제곱근). stl, math.h, 씨쁠쁠, example code, 예제코드C++ Math - sqrt (square root, 제곱근, 루트). stl, math.h, 씨쁠쁠, example code, 예제코드

 

 

math.h 헤더 추가해주고,

 

sqrt    -> 제곱근 (square root)

 

 

반환되는 자료형만 차이가 있고 sqrt, sqrtf, sqrtl 다 같은 기능

 

There are some difference between sqrt, sqrtf, and sqrtl. All is the same square root function, but return type.

 

 

msdn below

 https://docs.microsoft.com/ko-kr/cpp/c-runtime-library/reference/sqrt-sqrtf-sqrtl?view=vs-2019

 

 

#include <iostream>
#include <math.h>

using namespace std;

int main(int argc, char *argv[]) {

	double returnVal;

	returnVal = sqrt(1938);
	cout << returnVal << endl;

	returnVal = sqrt(9);
	cout << returnVal << endl;

	returnVal = sqrt(99);
	cout << returnVal << endl;
}

 

Result below

 

44.0227

3

9.94987

 

 

2019/04/02 - [Programming/C++] - How to find if vector contains specific value or not in C++, 씨쁠쁠 stl 벡터에 특정 값이 이미 있는지 확인하는 방법

 

 

2019/03/31 - [Algorithm/Leet Code] - LeetCode #540 SingleElementInASortedArray. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접

2019/03/27 - [Algorithm/Leet Code] - LeetCode #451 SortCharactersByFrequency. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접

2019/03/25 - [Algorithm/Leet Code] - LeetCode #442 FindAllDuplicatesInAnArray. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접

2019/03/17 - [Algorithm/Leet Code] - LeetCode #292 NimGame. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접

2019/03/12 - [Algorithm/Leet Code] - LeetCode #566 ReshapeTheMatrix. Algorithm,알고리즘,LeetCode,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive,datastructure,techinterview,coding,코딩인터뷰,기술면접,Matlab resh..

 

 

2019/02/12 - [Programming/C++] - How to use map in c++ STL, c++ 맵 STL 사용방법/초기화/예제, java, example, sample, library, find, insert, first

2019/02/04 - [Programming/C++] - How to add DLL / external lib file to VisualStudio, 비주얼스튜디오 외부라이브러리 dll 파일 추가 방법, example, c++ java api

2018/12/26 - [Programming/Software Architecture] - Perfecting OO's Small Classes and Short Methods. 완벽한 객체지향의 작은 클래스와 짧은 메소드, Book:ThoughtWorks Anthology, Java,cpp,자바,oop,좋은코드,객체지향프로그래밍

 

2018/12/21 - [Programming/Programming Language] - Scala Advantages & Disadvantages 스칼라 장단점, 객체지향, 함수적, 절차지향적, 프로그래밍언어

 

2018/11/28 - [Programming/Image Processing] - OpenCV How to get min/max value from matrix, 매트릭스 최소값/최대값. Java,c++,cpp,imageprocessing

 

 

2019/01/12 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #60 sudoku. Algorithm,알고리즘,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive

2019/01/12 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #59 spiralNumbers. Algorithm,알고리즘,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive

2019/01/08 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #58 messageFromBinaryCode. Algorithm,알고리즘,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive

2019/01/07 - [Algorithm/Code Fights (Code Signal)] - Aracade Intro #57 fileNaming. Algorithm,알고리즘,Codefights,CodeSignal,코드파이트,코드시그널,예제,문제해결능력,example,c++,java,재귀,recursive