-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
I'm not sure how JS numbers are really supposed to work, but currently dynamic
blocks do what I want, and dynamic
interfaces do not:
dynamic JSMath {
shared formal Float sin(Float x);
}
JSMath jsMath {
dynamic { return \iMath; }
}
shared void run() {
print(jsMath.sin(3.14159/2.0)); // 0.9999999999991198 (good)
print((jsMath.sin(3.14159/2.0) of Anything) is Float); // true (good)
print((jsMath.sin(3.14159/2.0) of Anything) is Integer); // false (good)
print(jsMath.sin(0.0)); // 0 (Not 0.0)
print((jsMath.sin(0.0) of Anything) is Float); // false
print((jsMath.sin(0.0) of Anything) is Integer); // true
Float result;
dynamic {
result = \iMath.sin(0.0);
}
print(result); // 0.0 (good)
print((result of Anything) is Float); // true (good)
print((result of Anything) is Integer); // false (good)
}
As you can see, sometimes I wind up with a Ceylon Float
, and sometimes an Integer
. This also affects results like -0.0
vs. +0.0
, and perhaps infinity and undefined.