1127 (0.0 uncheckedDivide:0) asShortFloat storeString. |
1127 (0.0 uncheckedDivide:0) asShortFloat storeString. |
1128 DecimalPointCharacterForPrinting := $. |
1128 DecimalPointCharacterForPrinting := $. |
1129 " |
1129 " |
1130 ! ! |
1130 ! ! |
1131 |
1131 |
|
1132 !ShortFloat methodsFor:'private accessing'! |
|
1133 |
|
1134 basicAt:index |
|
1135 "return an internal byte of the float. |
|
1136 The value returned here depends on byte order, float representation etc. |
|
1137 Therefore, this method should be used strictly private. |
|
1138 |
|
1139 Notice: |
|
1140 the need to redefine this method here is due to the |
|
1141 inability of many machines to store floats in non-double aligned memory. |
|
1142 Therefore, on some machines, the first 4 bytes of a float are left unused, |
|
1143 and the actual float is stored at index 5 .. 12. |
|
1144 To hide this at one place, this method knows about that, and returns |
|
1145 values as if this filler wasnt present." |
|
1146 |
|
1147 %{ /* NOCONTEXT */ |
|
1148 |
|
1149 register int indx; |
|
1150 unsigned char *cp; |
|
1151 |
|
1152 /* |
|
1153 * notice the missing test for self being a nonNilObject - |
|
1154 * this can be done since basicAt: is defined both in UndefinedObject |
|
1155 * and SmallInteger |
|
1156 */ |
|
1157 if (__isSmallInteger(index)) { |
|
1158 indx = __intVal(index) - 1; |
|
1159 if (((unsigned)(indx)) < sizeof(float)) { |
|
1160 cp = (unsigned char *)(& (__ShortFloatInstPtr(self)->f_floatvalue)); |
|
1161 RETURN ( __mkSmallInteger(cp[indx] & 0xFF) ); |
|
1162 } |
|
1163 } |
|
1164 %}. |
|
1165 ^ self indexNotIntegerOrOutOfBounds:index |
|
1166 ! |
|
1167 |
|
1168 basicAt:index put:value |
|
1169 "set an internal byte of the float. |
|
1170 The value to be stored here depends on byte order, float representation etc. |
|
1171 Therefore, this method should be used strictly private. |
|
1172 |
|
1173 Notice: |
|
1174 the need to redefine this method here is due to the |
|
1175 inability of many machines to store floats in non-double aligned memory. |
|
1176 Therefore, on some machines, the first 4 bytes of a float are left unused, |
|
1177 and the actual float is stored at index 5 .. 12. |
|
1178 To hide this at one place, this method knows about that, and returns |
|
1179 values as if this filler wasnt present." |
|
1180 |
|
1181 %{ /* NOCONTEXT */ |
|
1182 register int indx, val; |
|
1183 unsigned char *cp; |
|
1184 |
|
1185 /* |
|
1186 * notice the missing test for self being a nonNilObject - |
|
1187 * this can be done since basicAt: is defined both in UndefinedObject |
|
1188 * and SmallInteger |
|
1189 */ |
|
1190 if (__bothSmallInteger(index, value)) { |
|
1191 val = __intVal(value); |
|
1192 if ((val & ~0xFF) == 0 /* i.e. (val >= 0) && (val <= 255) */) { |
|
1193 indx = __intVal(index) - 1; |
|
1194 if (((unsigned)(indx)) < sizeof(float)) { |
|
1195 cp = (unsigned char *)(& (__ShortFloatInstPtr(self)->f_floatvalue)); |
|
1196 cp[indx] = val; |
|
1197 RETURN ( value ); |
|
1198 } |
|
1199 } |
|
1200 } |
|
1201 %}. |
|
1202 value isInteger ifFalse:[ |
|
1203 " |
|
1204 the object to store should be an integer number |
|
1205 " |
|
1206 ^ self elementNotInteger |
|
1207 ]. |
|
1208 (value between:0 and:255) ifFalse:[ |
|
1209 " |
|
1210 the object to store must be a bytes value |
|
1211 " |
|
1212 ^ self elementBoundsError:value |
|
1213 ]. |
|
1214 ^ self indexNotIntegerOrOutOfBounds:index |
|
1215 ! ! |
|
1216 |
1132 !ShortFloat methodsFor:'special access'! |
1217 !ShortFloat methodsFor:'special access'! |
1133 |
1218 |
1134 exponent |
1219 exponent |
1135 "extract a normalized floats exponent. |
1220 "extract a normalized floats exponent. |
1136 The returned value depends on the float-representation of |
1221 The returned value depends on the float-representation of |