Maximum length of a rfc 4122 version 4 - rfc

I see http://www.ietf.org/rfc/rfc4122.txt
What's the maximum length of a RFC 4122 version 4? In other words, is it always the same maximum length as this example string value taken from the document? f81d4fae-7dec-11d0-a765-00a0c91e6bf6
I think the answer lies in the section that says "The formal definition of the UUID string representation is provided by the following ABNF"
I wanted a second opinion for the sake of a database table column (varchar).
Thanks!

According to RFC 4122:
A UUID is 128 bits long, and can guarantee
uniqueness across space and time.
But if we want to know the string representation, we need to check the ABNF:
UUID = time-low "-" time-mid "-"
time-high-and-version "-"
clock-seq-and-reserved
clock-seq-low "-" node
time-low = 4hexOctet
time-mid = 2hexOctet
time-high-and-version = 2hexOctet
clock-seq-and-reserved = hexOctet
clock-seq-low = hexOctet
node = 6hexOctet
hexOctet = hexDigit hexDigit
hexDigit =
"0" / "1" / "2" / "3" / "4" / "5" / "6" / "7" / "8" / "9" /
"a" / "b" / "c" / "d" / "e" / "f" /
"A" / "B" / "C" / "D" / "E" / "F"
We have a total of 16 hexOctet. We count 2 characters by hexOctet plus 4 times the character "-". We have a total of 16 * 2 + 4 = 36 characters regardless of the version.

Related

Why are the variables are not taking the desired values

I have to check how many hundreds are there in a number and translate that number to letters. For example the number 700. I have done the following code:
DATA(lv_dmbtr) = ZDS_FG-DMBTR. //Declared local variable of type DMBTR, thus DMBTR=700.
lv_dmbtr = ZDS_FG-DMBTR MOD 100. //Finding how many times 700 is in 100 via MOD and putting the value in lv_dmbtr.
IF lv_dmbtr LE 9. //The value is less or equal than 9(if larger means that the DMBTR is larger than hundreds,
e.g. 8000)
lv_hundred = lv_dmbtr / 100. // Divide the 700 with 100, taking the number 7.
lv_hundred_check = lv_hundred MOD 1. // Then taking the value of 7 into the new variable, done in case the
lv_hundred is a decimal value, e.g. 7.32.
IF lv_hundred_check > 0.
CALL FUNCTION 'SPELL_AMOUNT'
EXPORTING
amount = lv_hundred_check
* CURRENCY = ' '
* FILLER = ' '
LANGUAGE = SY-LANGU
IMPORTING
in_words = lv_hundred_string // the value is put in the new string
EXCEPTIONS
not_found = 1
too_large = 2
OTHERS = 3.
ENDIF.
Now when I debugg the code, all the variables have the value 0. Thus, lv_dmbtr, lv_hundred, lv_hundred_check all have the value 0.
May anyone of you know where the problem may be?
Thank you in advance!
Sorry for writing a lot in the code, just wanted to clarify as much as I could what I had done.
yes so I want to display the value of a specific number 700-> seven, 1400-> four.
So the basic formula to get the hundred in a number is the following: Find out how many times 100 fits completely into your number with integer division.
99 / 100 = 0
700 / 100 = 7
701 / 100 = 7
1400 / 100 = 14
1401 / 100 = 14
Now you can simply take this number MOD 10 to get the the individual hundreds.
0 MOD 10 = 0
7 MOD 10 = 7
14 MOD 10 = 4
Keep in mind that ABAP, in contrast to many other programming languages, rounds automatically. So in code this would be:
CONSTANTS lc_hundred TYPE f VALUE '100.0'.
DATA(lv_number) = 1403.
DATA(lv_hundred_count) = CONV i( floor( ( abs( lv_number ) / lc_hundred ) ) MOD 10 ).

How to denote at least one repetition in EBNF?

https://en.wikipedia.org/wiki/Extended_Backus–Naur_form
The above article mentions that curly braces denote repetition of arbitrary times (incl. zero), while square brackets denote at most one repetition.
What I want however, is at least one repetition - that is, a terminal or a nonterminal must appear at least once.
Well I can describe it like that:
production = nonterminal, { nonterminal };
But I thought the point of EBNF over BNF was to avoid the need of this kind of "hacks".
The Wikipedia article also mentions:
EBNF also provides, among other things, the syntax to describe repetitions (of a specified number of times), to exclude some part of a production, and to insert comments in an EBNF grammar.
But does EBNF provide the syntax to describe at least one repetition?
Place a minus (except-symbol) after the final brace.
production = { nonterminal }-;
ISO/IEC 14977 : 1996(E)
5.8 Syntactic-term
When a syntactic-term is a single syntactic-factor it represents any
sequence of symbols represented by that syntactic-factor.
When a syntactic-term is a syntactic-factor followed by an
except-symbol followed by a syntactic-exception it represents any
sequence of symbols that satisfies both of the conditions:
a) it is a sequence of symbols represented by the syntactic-factor,
b) it is not a sequence of symbols represented by the
syntactic-exception.
As examples the following syntax-rules illustrate the facilities
provided by the except-symbol.
letter = "A" | "B" | "C" | "D" | "E" | "F"
| "G" | "H" | "I" | "J" | "K" | "L" | "M"
| "N" | "O" | "P" | "Q" | "R" | "S" | "T"
| "U" | "V" | "W" | "X" | "Y" | "Z";
vowel = "A" | "E" | "I" | "O" |"U";
consonant = letter - vowel;
ee = {"A"}-, "E";
Terminal-strings defined by these rules are as follows:
letter: A B C D E F G H I J etc.
vowel: A E I O U
consonant: B C D F G H J K L M etc.
ee: AE AAE AAAE AAAAE AAAAAE etc.
NOTE — {"A"}- represents a sequence of one or more A’s because it is a
syntactic-term with an empty syntactic-exception.
Note that in the second paragraph (emphasis added), satisfies both of the conditions. That is, both the syntactic-factor and the syntactic-exception must be satisfied. The braces still mean repetition. This results in one or more to satisfy the syntax, even though the exception is empty.

How to convert Character Numerals into Numeric format?

I am trying to convert some String of Characters into Numeric form and then further incrementing it.
For Example : XX1-XXXXX.01.01.01.01 should be incremented to XX1-XXXXX.01.01.01.02 and if it reaches to XX1-XXXXX.01.01.01.99 then next increment should be XX1-XXXXX.01.01.02.00 and it continues for next node also.
XX1-XXXXX.01.01.01.01 is in Character Format.
Any Possible Solution?
This one is not compatible down to ABAP 700 like szakos but I want to bring in another solution:
FORM increment
CHANGING
fcw_out TYPE string.
DATA lw_as_n TYPE n LENGTH 8.
SPLIT fcw_out AT '.' INTO DATA(lw_start) DATA(lw_rest).
REPLACE ALL OCCURRENCES OF '.' IN lw_rest WITH ''.
lw_as_n = lw_rest + 1.
fcw_out = |{ lw_start }.{ lw_as_n(2) }.{ lw_as_n+2(2) }.{ lw_as_n+4(2) }.{ lw_as_n+6(2) }|.
ENDFORM.
" ------------------------------------------------
" Test run
" ------------------------------------------------
DATA(w_str) = `XX1-XXXXX.01.01.01.99`.
PERFORM increment CHANGING w_str. " ==> XX1-XXXXX.01.01.02.00
You can achieve this by converting the numerical parts of the node to a number and write it back after increasing. Simple example code:
DATA: l_node TYPE c LENGTH 21,
l_node_new TYPE c LENGTH 21,
l_help TYPE c LENGTH 11,
l_num TYPE n LENGTH 8,
l_node_pos TYPE int4,
l_num_pos TYPE int4.
l_node_new = l_node = 'XX1-XXXXX.01.01.01.01'.
l_help = l_node+10(*).
REPLACE ALL OCCURRENCES OF '.' IN l_help WITH ''.
CONDENSE l_help.
l_num = l_help.
DO 100 TIMES.
ADD 1 TO l_num.
ENDDO.
DO 4 TIMES.
l_node_pos = 10 + ( sy-index - 1 ) * 3.
l_num_pos = 0 + ( sy-index - 1 ) * 2.
l_node_new+l_node_pos(2) = l_num+l_num_pos(2).
ENDDO.
WRITE / l_node.
WRITE / l_node_new.
The output is:
The ABAP version was 700 so this is the "old" syntax, but should work on newer versions.

How to remove zeroes after the decimal point as an expression in SSRS

I have the following expression in one of my textbox in my SSRS Report:
=IIF(IsNothing(Lookup(Trim(Fields!venta_Cod_vendedor.Value) & "-" & ReportItems!Textbox233.Value, Fields!AgregarVentas.Value, Fields!venta_prom_sem.Value, "EfectividadDeFrecuencias_Ventas")) = True
,"0"
,IIF(Lookup(Trim(Fields!venta_Cod_vendedor.Value) & "-" & ReportItems!Textbox233.Value, Fields!Agregar.Value, Fields!total_cant_pos.Value, "EfectividadDeFrecuencias_Total") <> "0"
,FormatNumber(Lookup(Trim(Fields!venta_Cod_vendedor.Value) & "-" & ReportItems!Textbox233.Value, Fields!AgregarVentas.Value, Fields!venta_frecuencia.Value, "EfectividadDeFrecuencias_Ventas")
/ Lookup(Trim(Fields!venta_Cod_vendedor.Value) & "-" & ReportItems!Textbox233.Value, Fields!Agregar.Value, Fields!total_cant_pos.Value, "EfectividadDeFrecuencias_Total"),2)
,"0"))
That division will give me an int64 number, 15 digits (If such math operation gives that amount of decimal digits).
So the results are:
Now here is the tricky part:
My code behind that grabs the Dataset does a round and converts to decimal and then shows to a Crystal Report.
dr.venta_prom_sem = (Convert.ToDouble(dr.total_cant_pos) != 0 ? (Math.Round((Convert.ToDouble(dr.venta_frecuencia) / Convert.ToDouble(dr.total_cant_pos)), 2)).ToString() : "0");
So this will give me:
as you can see if I use a format Number the 1.3 will convert to 1,30 and that will be wrong, same as 1 (1,00). Now 1,339...etc will give me 1,34 and that is fine.
But check the 1.065, with FormatNumber that will give me 1.07 instead of 1.06.
So the thing is, how can I format my numbers to be the last non zero digit after the decimal point AND select the lower value if the (in this case) 3rd value is 5, instead of 1.07 be 1.06. I think If I use Ceiling or Floor it gives me the integer part.
Try this:
=ROUND(1.339,2,MidpointRounding.ToEven)
This gives: 1.34
And
=ROUND(1.065,2,MidpointRounding.ToEven)
Gives: 1.06
Let me know if this was helpful.

in VB.net, if nth digit after decimal is Zero, then Round function will apply for 7 digit

let say n decimal = 0.996010569
I have applied below code (round on 6th digit) :
txtDiscountRate.Text = Math.Round(Val(txtDiscountRate.Text.Trim), 6)
But since here its 6th digit is 0 (Zero), so its value become 0.99601.
But i wish it would be 0.996011.
logic is: if 6th digit is 0 or < 5 then it do Round from 7th digit
then our calculation will be right.
Please provide Code in VB.net.
Jerry
in above code.
CInt(Str(1).Char(5)) is showing error this error -----> " 'Char' is not a member of 'String'".
Scenario is described below:
in txtDiscountRate.text have value "0.996010500406591" .
in my coding i did
txtDiscountRate.Text = Math.Round(Val(txtDiscountRate.Text.Trim), 6) . (means considering round till digit throught)
so it giving value 0.99601 which is because of 6th digit after decimal is 0,
but i want to put condition, in decimal value, if on 6th digit after decimal is ( 0 or 1 or 2 or 3 or 4 ) and 7th digit after decimal is available then it round till 7th position.
else it round till 6th position.
Use the FormatNumber() function.
Maybe not the best and prettiest solution, but you can give it a try...
Dim Dec As Decimal = 0.996010569
Dim str() As String = Split(CStr(Dec), ".")
If CInt(Str(1).Chars(5)) < 5 Then 'It's Char number 5 since it's a zero-based index. So the first number = Index 0.
txtDiscountRate.Text = Math.Round(Val(txtDiscountRate.Text.Trim), 7)
Else
txtDiscountRate.Text = Math.Round(Val(txtDiscountRate.Text.Trim), 6)
End If