- extended evcontroller
- remote objects - new ev drivers for oxford IPS,ITC,ILM and LC M.Z.
This commit is contained in:
@@ -227,31 +227,38 @@ void StrNLink(StrBuf *buf, char *str, int length) {
|
||||
|
||||
void flt_to_char4(double f, char buf[4]) {
|
||||
double m;
|
||||
int e, res, ir;
|
||||
int e;
|
||||
long res;
|
||||
|
||||
m=frexp(f, &e);
|
||||
e=e+EXP_OFFS;
|
||||
if (e<0 || m==0) {
|
||||
res=0; m=0;
|
||||
m = frexp(f, &e);
|
||||
e += EXP_OFFS;
|
||||
if (e < 0 || m == 0) {
|
||||
res = 0; m = 0;
|
||||
} else {
|
||||
if (e>255) {
|
||||
res=255*TWO_23+(TWO_23-1); /* max. representable number */
|
||||
if (e > 255) {
|
||||
res = 255 * TWO_23 + (TWO_23 - 1); /* max. representable number */
|
||||
} else {
|
||||
res=e*TWO_23+(int)(0.5+(fabs(m*2)-1.0)*TWO_23);
|
||||
res = (long)(0.5 + (fabs(m * 2) - 1.0) * TWO_23);
|
||||
/* here we may think about the case, where m is just a little less than 1.0:
|
||||
the mantissa part overflows to bit23, but, the result would be o.k., since this
|
||||
just increases the exponent by one, and the mantissa bits get all zero.
|
||||
but what happens when e is already 255 ? the next line handles this */
|
||||
if (res == TWO_23 && e == 255) res--;
|
||||
res += e * TWO_23;
|
||||
}
|
||||
}
|
||||
buf[0]=res % 256; res=res/256;
|
||||
buf[1]=res % 256; res=res/256;
|
||||
buf[2]=res % 256; res=res/256;
|
||||
if (m<0) {
|
||||
buf[3]=res-128;
|
||||
buf[0] = res % 256; res = res / 256;
|
||||
buf[1] = res % 256; res = res / 256;
|
||||
buf[2] = res % 256; res = res / 256;
|
||||
if (m < 0) {
|
||||
buf[3] = res - 128;
|
||||
} else {
|
||||
buf[3]=res;
|
||||
buf[3] = res;
|
||||
}
|
||||
}
|
||||
|
||||
double flt_from_char4(char buf[4]) {
|
||||
int s, i, b0, b1, b2, b3;
|
||||
long i, b0, b1, b2, b3;
|
||||
|
||||
b0=buf[0]; if (b0<0) b0+=256;
|
||||
b1=buf[1]; if (b1<0) b1+=256;
|
||||
|
||||
Reference in New Issue
Block a user