73
74 /** ECMA 15.7.3.4 NaN */
75 @Property(attributes = Attribute.NON_ENUMERABLE_CONSTANT, where = Where.CONSTRUCTOR)
76 public static final double NaN = Double.NaN;
77
78 /** ECMA 15.7.3.5 negative infinity */
79 @Property(attributes = Attribute.NON_ENUMERABLE_CONSTANT, where = Where.CONSTRUCTOR)
80 public static final double NEGATIVE_INFINITY = Double.NEGATIVE_INFINITY;
81
82 /** ECMA 15.7.3.5 positive infinity */
83 @Property(attributes = Attribute.NON_ENUMERABLE_CONSTANT, where = Where.CONSTRUCTOR)
84 public static final double POSITIVE_INFINITY = Double.POSITIVE_INFINITY;
85
86 private final double value;
87 private final boolean isInt;
88 private final boolean isLong;
89
90 // initialized by nasgen
91 private static PropertyMap $nasgenmap$;
92
93 static PropertyMap getInitialMap() {
94 return $nasgenmap$;
95 }
96
97 private NativeNumber(final double value, final ScriptObject proto, final PropertyMap map) {
98 super(proto, map);
99 this.value = value;
100 this.isInt = isRepresentableAsInt(value);
101 this.isLong = isRepresentableAsLong(value);
102 }
103
104 NativeNumber(final double value, final Global global) {
105 this(value, global.getNumberPrototype(), getInitialMap());
106 }
107
108 private NativeNumber(final double value) {
109 this(value, Global.instance());
110 }
111
112
113 @Override
114 public String safeToString() {
115 return "[Number " + toString() + "]";
116 }
117
118 @Override
119 public String toString() {
120 return Double.toString(getValue());
121 }
122
123 /**
124 * Get the value of this Number
125 * @return a {@code double} representing the Number value
|
73
74 /** ECMA 15.7.3.4 NaN */
75 @Property(attributes = Attribute.NON_ENUMERABLE_CONSTANT, where = Where.CONSTRUCTOR)
76 public static final double NaN = Double.NaN;
77
78 /** ECMA 15.7.3.5 negative infinity */
79 @Property(attributes = Attribute.NON_ENUMERABLE_CONSTANT, where = Where.CONSTRUCTOR)
80 public static final double NEGATIVE_INFINITY = Double.NEGATIVE_INFINITY;
81
82 /** ECMA 15.7.3.5 positive infinity */
83 @Property(attributes = Attribute.NON_ENUMERABLE_CONSTANT, where = Where.CONSTRUCTOR)
84 public static final double POSITIVE_INFINITY = Double.POSITIVE_INFINITY;
85
86 private final double value;
87 private final boolean isInt;
88 private final boolean isLong;
89
90 // initialized by nasgen
91 private static PropertyMap $nasgenmap$;
92
93 private NativeNumber(final double value, final ScriptObject proto, final PropertyMap map) {
94 super(proto, map);
95 this.value = value;
96 this.isInt = isRepresentableAsInt(value);
97 this.isLong = isRepresentableAsLong(value);
98 }
99
100 NativeNumber(final double value, final Global global) {
101 this(value, global.getNumberPrototype(), $nasgenmap$);
102 }
103
104 private NativeNumber(final double value) {
105 this(value, Global.instance());
106 }
107
108
109 @Override
110 public String safeToString() {
111 return "[Number " + toString() + "]";
112 }
113
114 @Override
115 public String toString() {
116 return Double.toString(getValue());
117 }
118
119 /**
120 * Get the value of this Number
121 * @return a {@code double} representing the Number value
|