"Sub Range" Integer Functions ....!
Recently I came accross a C# function that gets the first N Digits of a Integer Number BUT with the restriction to NOT convert the number to a string !
http://www.codeproject.com/Tips/1096544/Get-First-N-digits-of-a-Number
Without having a specific need for this in Lisp, i decided to translate it to Lisp and imitate the SUBSTR lisp function conforming to the above Restriction.
The Functions do not use any string conversion !
I would like to share the functions with you...
The attached file contains 2 functions :
(subInt integerNumber subrange ) this is the exact translation of the C# function with 2 integer arguments
: (subInt 13453543 5 )
13453
: (subInt 13453543 0 )
nil
: (subInt 13453543 7 )
1345354
: (subInt 13453543 2 )
13
(subDigits integerNumber Startposition Length_of_Digit_Range ResultFlag)
: (subDigits 13453543 2 5 T )
(3 4 5 3 5)
: (subDigits 13453543 2 5 nil )
34535
Read the code for documentation on the arguments
Enjoy if you need them ...
http://www.codeproject.com/Tips/1096544/Get-First-N-digits-of-a-Number
Without having a specific need for this in Lisp, i decided to translate it to Lisp and imitate the SUBSTR lisp function conforming to the above Restriction.
The Functions do not use any string conversion !
I would like to share the functions with you...
The attached file contains 2 functions :
(subInt integerNumber subrange ) this is the exact translation of the C# function with 2 integer arguments
: (subInt 13453543 5 )
13453
: (subInt 13453543 0 )
nil
: (subInt 13453543 7 )
1345354
: (subInt 13453543 2 )
13
(subDigits integerNumber Startposition Length_of_Digit_Range ResultFlag)
: (subDigits 13453543 2 5 T )
(3 4 5 3 5)
: (subDigits 13453543 2 5 nil )
34535
Read the code for documentation on the arguments
Enjoy if you need them ...
0