aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKenneth Lundin <[email protected]>2010-09-10 12:06:43 +0200
committerKenneth Lundin <[email protected]>2010-09-10 12:06:43 +0200
commit836f70094ff092b3b4dd4e007f3a019518e68910 (patch)
tree95618951d4c93d0ce10d13fc9d97d07d57b9ef31 /lib
parentca05a52db5d420975d87d427243531e9c7891d69 (diff)
parent727ea85b458865daf39fef07a8cd8308420e2a1a (diff)
downloadotp-836f70094ff092b3b4dd4e007f3a019518e68910.tar.gz
otp-836f70094ff092b3b4dd4e007f3a019518e68910.tar.bz2
otp-836f70094ff092b3b4dd4e007f3a019518e68910.zip
Merge branch 'kenneth/asn1/uper_contrained_number/OTP-8779' into dev
* kenneth/asn1/uper_contrained_number/OTP-8779: Fix bug in UNALIGNED PER regarding encode/decode of constrained number with valuerange > 1024
Diffstat (limited to 'lib')
-rw-r--r--lib/asn1/src/asn1rt_uper_bin.erl29
1 files changed, 6 insertions, 23 deletions
diff --git a/lib/asn1/src/asn1rt_uper_bin.erl b/lib/asn1/src/asn1rt_uper_bin.erl
index a964b835ae..abe178a69e 100644
--- a/lib/asn1/src/asn1rt_uper_bin.erl
+++ b/lib/asn1/src/asn1rt_uper_bin.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2009. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2010. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -1611,25 +1611,8 @@ complete_NFP(InList) when is_bitstring(InList) ->
%% 10.5.6 NOTE: If "range" satisfies the inequality 2^m < "range" =<
%% 2^(m+1) then the number of bits = m + 1
-num_bits(1) -> 0;
-num_bits(2) -> 1;
-num_bits(R) when R =< 4 ->
- 2;
-num_bits(R) when R =< 8 ->
- 3;
-num_bits(R) when R =< 16 ->
- 4;
-num_bits(R) when R =< 32 ->
- 5;
-num_bits(R) when R =< 64 ->
- 6;
-num_bits(R) when R =< 128 ->
- 7;
-num_bits(R) when R =< 256 ->
- 8;
-num_bits(R) when R =< 512 ->
- 9;
-num_bits(R) when R =< 1024 ->
- 10;
-num_bits(R) ->
- 1+num_bits(R bsr 1).
+
+num_bits(N) ->
+ num_bits(N,1,0).
+num_bits(N,T,B) when N=<T->B;
+num_bits(N,T,B) ->num_bits(N,T bsl 1, B+1).