Sgn Function

ํ•จ์ˆ˜์— ์ „๋‹ฌ๋œ ๊ฐ’์ด ์–‘์ˆ˜์ธ์ง€, ์Œ์ˆ˜์ธ์ง€, 0์ธ์ง€๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” -1์—์„œ 1 ์‚ฌ์ด์˜ ์ •์ˆ˜๋ฅผ ๊ตฌํ•ฉ๋‹ˆ๋‹ค.

๊ตฌ๋ฌธ:


Sgn (Number)

๋ฐ˜ํ™˜ ๊ฐ’:

Integer

๋งค๊ฐœ ๋ณ€์ˆ˜:

Number: ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ตฌํ•  ๊ฐ’์„ ๊ฒฐ์ •ํ•˜๋Š” ์ˆซ์ž ์‹์ž…๋‹ˆ๋‹ค.

Number

๋ฐ˜ํ™˜ ๊ฐ’

์Œ์ˆ˜

Sgn์€ -1์„ ๊ตฌํ•ฉ๋‹ˆ๋‹ค.

0

Sgn์€ 0์„ ๊ตฌํ•ฉ๋‹ˆ๋‹ค.

์–‘์ˆ˜

Sgn์€ 1์„ ๊ตฌํ•ฉ๋‹ˆ๋‹ค.


Error codes:

5 ์ž˜๋ชป๋œ ํ”„๋กœ์‹œ์ € ํ˜ธ์ถœ์ž…๋‹ˆ๋‹ค.

์˜ˆ:


Sub ExampleSgn
    Print sgn(-10) REM returns -1
    Print sgn(0) REM returns 0
    Print sgn(10) REM returns 1
End Sub

Please support us!