Skip to content

Commit

Permalink
fix: precision reading of fields when parsing binary VOTable
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatthieu3 committed Oct 9, 2024
1 parent d792b2e commit 84f998a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/js/vo/VOTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ export class VOTable {
cellSizeInBytes = tabDataSize[dataType];
}
let value;
let prec;
switch (dataType) {
case 'short':
value = view.getUint16(numBytesRead);
Expand All @@ -374,11 +375,17 @@ export class VOTable {
break;
case 'float':
value = view.getFloat32(numBytesRead);
value = +value.toFixed(fields[fieldIdx].precision); // round (arrondi)
prec = fields[fieldIdx].precision;
if (prec) {
value = +value.toFixed(prec); // round (arrondi)
}
break;
case 'double':
value = view.getFloat64(numBytesRead);
value = +value.toFixed(fields[fieldIdx].precision); // round (arrondi)
prec = fields[fieldIdx].precision;
if (prec) {
value = +value.toFixed(prec); // round (arrondi)
}
break;
case 'unsignedByte':
value = view.getUint8(numBytesRead);
Expand Down

0 comments on commit 84f998a

Please sign in to comment.