We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Sgn Machine
Jump to navigation
Jump to search
Sgn machine is designed by PSTF.
Description
The function of the Sgn machine is to receive a real number. If it is positive, it outputs 1; if it is negative, it outputs -1; if it is 0, it outputs 0 infinitely.
Challenge Area
The Second Coming
import math
open x: Float;
x = Float(input());
x = sgn(x);
if x != 0:
print(x)
else:
while true:
print(x)
endwhile
endif
Python
import math
x = float(input());
x = sgn(x);
if x != 0:
print(x)
else:
while True:
print(x)