내인생PLUS 2022. 8. 17. 10:05
728x90

https://users.rust-lang.org/t/how-do-i-implement-the-js-math-hypot-function-in-rust/79580

 

How do I implement the JS 'Math.hypot()' function in Rust?

I saw this: Function js_sys::Math::hypot pub fn hypot(x: f64, y: f64) -> f64 But how do I use this? I can't use use Function js_sys::Math::hypot to make use of it, and copy pasting it doesn't work either. Alternatively, is there a Rust function like this a

users.rust-lang.org






https://doc.rust-lang.org/std/primitive.f64.html#method.hypot

 

f64 - Rust

Not a Number (NaN). Note that IEEE-745 doesn’t define just a single NaN value; a plethora of bit patterns are considered to be NaN. Furthermore, the standard makes a difference between a “signaling” and a “quiet” NaN, and allows inspecting its

doc.rust-lang.org

 



C언어에서 hypot function
https://www.programiz.com/c-programming/library-function/math.h/hypot

 

C hypot() - C Standard Library

hypot() function Prototype double hypot(double p, double b); h = √(p2+b2) in mathematics is equivalent to h = hypot(p, b); in C Programming. The hypot() function is defined in math.h header file. Example: C hypot() Function #include #include int main()

www.programiz.com





https://youtu.be/5mqHzWIzruM



 

https://www.khanacademy.org/math/geometry/hs-geo-trig/xff63fac4:hs-geo-trig-ratios-similarity/a/opposite-adjacent-hypotenuse

 

Hypotenuse, opposite, and adjacent (article) | Khan Academy

In a right triangle, the hypotenuse is the longest side, an "opposite" side is the one across from a given angle, and an "adjacent" side is next to a given angle.

www.khanacademy.org


 

C언어 코드

https://github.com/YoungHaKim7/rust_polyglot/commit/5deadb520716bac5c6c1208b1f53e08c650bc9c1

 

gcc -o hypo -Wall hypo_math.c____hypotenuse function · YoungHaKim7/rust_polyglot@5deadb5

Show file tree Showing 38 changed files with 657 additions and 2 deletions.

github.com

 

 

 

 

 

RUst 코드 바뀌기 전과 지금 업데이트 되고 난 후 

https://github.com/YoungHaKim7/rust_polyglot/commit/0b51c00e8431768d767681831eee7dd193f0629d

 

Rust1.63.0 hypotenuse__ · YoungHaKim7/rust_polyglot@0b51c00

Showing 1 changed file with 3 additions and 9 deletions.

github.com

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

반응형