Skip to content

Commit 2aa6591

Browse files
committed
add conditions to use the U marker
1 parent 31eabba commit 2aa6591

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

saveubjson.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -645,12 +645,17 @@
645645
end
646646
if(isempty(type))
647647
% todo - need to consider negative ones separately
648-
id= histc(abs(max(double(mat(:)))),[0 2^7 2^15 2^31 2^63]);
649-
if(isempty(id~=0))
650-
error('high-precision data is not yet supported');
648+
maxval=max(double(mat(:)));
649+
if(max(double(mat(:)))>=0 && maxval<=255)
650+
type='U';
651+
else
652+
id= histc(abs(maxval),[0 2^7 2^15 2^31 2^63]);
653+
if(isempty(id~=0))
654+
error('high-precision data is not yet supported');
655+
end
656+
key=Imarker(2:end);
657+
type=key(id~=0);
651658
end
652-
key=Imarker(2:end);
653-
type=key(id~=0);
654659
end
655660
if(~isvector(mat) && isnest==1)
656661
txt=cell2ubjson('',num2cell(mat,1),level,varargin{:});

0 commit comments

Comments
 (0)