Created
April 17, 2018 07:39
-
-
Save TkrUdagawa/885d25d8e242e39cc980abfe47d3e712 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0.00283329 | |
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
template <typename T> | |
T dist(T a, T b) { | |
T l2_a = 0.f; | |
l2_a += a * a; | |
T l2_b = 0.f; | |
l2_b += b * b; | |
return l2_a + l2_b - 2 * a * b; | |
} | |
int main() { | |
double a, b; | |
float c, d; | |
a = 12.14362104; | |
b = 12.14078775; | |
c = a; | |
d = b; | |
std::cout << std::sqrt(dist(a, b)) << std::endl; | |
std::cout << std::sqrt(dist(c, d)) << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment