parent
7cb2879c03
commit
bac9cd24fc
|
@ -258,12 +258,12 @@ tiffer_rational(const struct tiffer *self, const struct tiffer_entry *entry,
|
||||||
*denominator = (int32_t) self->un->u32(entry->p + 4);
|
*denominator = (int32_t) self->un->u32(entry->p + 4);
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
if (!tiffer_integer(self, entry, numerator))
|
if (tiffer_integer(self, entry, numerator)) {
|
||||||
return false;
|
|
||||||
|
|
||||||
*denominator = 1;
|
*denominator = 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -275,14 +275,7 @@ tiffer_real(
|
||||||
|
|
||||||
// Somewhat excessively lenient, intended for display.
|
// Somewhat excessively lenient, intended for display.
|
||||||
switch (entry->type) {
|
switch (entry->type) {
|
||||||
int64_t integer;
|
int64_t numerator, denominator;
|
||||||
case RATIONAL:
|
|
||||||
*out = self->un->u32(entry->p) / (double) self->un->u32(entry->p + 4);
|
|
||||||
return true;
|
|
||||||
case SRATIONAL:
|
|
||||||
*out = (int32_t) self->un->u32(entry->p) /
|
|
||||||
(double) (int32_t) self->un->u32(entry->p + 4);
|
|
||||||
return true;
|
|
||||||
case FLOAT:
|
case FLOAT:
|
||||||
*out = *(float *) entry->p;
|
*out = *(float *) entry->p;
|
||||||
return true;
|
return true;
|
||||||
|
@ -290,12 +283,12 @@ tiffer_real(
|
||||||
*out = *(double *) entry->p;
|
*out = *(double *) entry->p;
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
if (!tiffer_integer(self, entry, &integer))
|
if (tiffer_rational(self, entry, &numerator, &denominator)) {
|
||||||
return false;
|
*out = (double) numerator / denominator;
|
||||||
|
|
||||||
*out = integer;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
Loading…
Reference in New Issue