Task

Create a boolean function which takes in a string and tells whether it is a numeric string (floating point and negative numbers included) in the syntax the language uses for numeric literals or numbers converted from strings.




Other tasks related to string operations:

Metrics
 Array length
 String length
 Copy a string
 Empty string  (assignment)
Counting
 Word frequency
 Letter frequency
 Jewels and stones
 I before E except after C
 Bioinformatics/base count
 Count occurrences of a substring
 Count how many vowels and consonants occur in a string
Remove/replace
 XXXX redacted
 Conjugate a Latin verb
 Remove vowels from a string
 String interpolation (included)
 Strip block comments
 Strip comments from a string
 Strip a set of characters from a string
 Strip whitespace from a string -- top and tail
 Strip control codes and extended characters from a string
Anagrams/Derangements/shuffling
 Word wheel
 ABC problem
 Sattolo cycle
 Knuth shuffle
 Ordered words
 Superpermutation minimisation
 Textonyms (using a phone text pad)
 Anagrams
 Anagrams/Deranged anagrams
 Permutations/Derangements
Find/Search/Determine
 ABC words
 Odd words
 Word ladder
 Semordnilap
 Word search
 Wordiff  (game)
 String matching
 Tea cup rim text
 Alternade words
 Changeable words
 State name puzzle
 String comparison
 Unique characters
 Unique characters in each string
 Extract file extension
 Levenshtein distance
 Palindrome detection
 Common list elements
 Longest common suffix
 Longest common prefix
 Compare a list of strings 
 Longest common substring
 Find common directory path
 Words from neighbour ones
 Change e letters to i in words
 Non-continuous subsequences
 Longest common subsequence
 Longest palindromic substrings
 Longest increasing subsequence
 Words containing "the" substring
 Sum of the digits of n is substring of n
 Determine if a string is numeric
 Determine if a string is collapsible
 Determine if a string is squeezable
 Determine if a string has all unique characters
 Determine if a string has all the same characters
 Longest substrings without repeating characters
 Find words which contains all the vowels
 Find words which contains most consonants
 Find words which contains more than 3 vowels
 Find words which first and last three letters are equals
 Find words which odd letters are consonants and even letters are vowels or vice_versa
Formatting
 Substring
 Rep-string
 Word wrap
 String case
 Align columns
 Literals/String
 Repeat a string
 Brace expansion
 Brace expansion using ranges
 Reverse a string
 Phrase reversals
 Comma quibbling
 Special characters
 String concatenation
 Substring/Top and tail
 Commatizing numbers
 Reverse words in a string
 Suffixation of decimal numbers
 Long literals, with continuations 
 Numerical and alphabetical suffixes
 Abbreviations, easy
 Abbreviations, simple
 Abbreviations, automatic
Song lyrics/poems/Mad Libs/phrases
 Mad Libs
 Magic 8-ball
 99 Bottles of Beer
 The Name Game (a song)
 The Old lady swallowed a fly
 The Twelve Days of Christmas
Tokenize
 Text between
 Tokenize a string
 Word break problem
 Tokenize a string with escaping
 Split a character string based on change of character
Sequences
 Show ASCII table
 De Bruijn sequences
 Self-referential sequences
 Generate lower case ASCII alphabet




 
/* ARM assembly Raspberry PI  */
/*  program strNumber.s   */
 
 
/*******************************************/
/* Constantes file                         */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
 
.equ BUFFERSIZE,          100
 
 
/* Initialized data */
.data
szMessNum: .asciz "Enter number : \n"
 
szMessError:            .asciz "String is not a number !!!\n"
szMessInteger:          .asciz "String is a integer.\n"
szMessFloat:            .asciz "String is a float.\n"
szMessFloatExp:         .asciz "String is a float with exposant.\n"
szCarriageReturn:       .asciz "\n"
 
/* UnInitialized data */
.bss 
sBuffer:              .skip BUFFERSIZE
 
/*  code section */
.text
.global main 
main: 
 
loop:
    ldr x0,qAdrszMessNum
    bl affichageMess
    mov x0,#STDIN                               // Linux input console
    ldr x1,qAdrsBuffer                          // buffer address 
    mov x2,#BUFFERSIZE                          // buffer size 
    mov x8, #READ                               // request to read datas
    svc 0                                       // call system
    ldr x1,qAdrsBuffer                          // buffer address 
    mov x2,#0                                   // end of string
    sub x0,x0,#1                                   // replace character 0xA
    strb w2,[x1,x0]                             // store byte at the end of input string (x0 contains number of characters)
    ldr x0,qAdrsBuffer
    bl controlNumber                            // call routine
    cmp x0,#0
    bne 1f
    ldr x0,qAdrszMessError                      // not a number
    bl affichageMess
    b 5f
1:
    cmp x0,#1
    bne 2f
    ldr x0,qAdrszMessInteger                    // integer
    bl affichageMess
    b 5f
2:
    cmp x0,#2
    bne 3f
    ldr x0,qAdrszMessFloat                      // float
    bl affichageMess
    b 5f
3:
    cmp x0,#3
    bne 5f
    ldr x0,qAdrszMessFloatExp                   // float with exposant
    bl affichageMess
5:
    b loop
 
100:                                            // standard end of the program
    mov x0, #0                                  // return code
    mov x8, #EXIT                               // request to exit program
    svc 0                                       // perform system call
qAdrszMessNum:            .quad szMessNum
qAdrszMessError:          .quad szMessError
qAdrszMessInteger:        .quad szMessInteger
qAdrszMessFloat:          .quad szMessFloat
qAdrszMessFloatExp:       .quad szMessFloatExp
qAdrszCarriageReturn:     .quad szCarriageReturn
qAdrsBuffer:              .quad sBuffer
/******************************************************************/
/*     control if string is number                          */ 
/******************************************************************/
/* x0 contains the address of the string */
/* x0 return 0 if not a number       */
/* x0 return 1 if integer   eq 12345 or -12345      */
/* x0 return 2 if float     eq 123.45 or 123,45  or -123,45     */
/* x0 return 3 if float with exposant  eq 123.45E30 or -123,45E-30        */
controlNumber:
    stp x1,lr,[sp,-16]!    // save  registers
    stp x2,x3,[sp,-16]!    // save  registers
    stp x4,x5,[sp,-16]!    // save  registers
    mov x1,#0
    mov x3,#0              // point counter 
1:
    ldrb w2,[x0,x1]
    cmp x2,#0              // end string ?
    beq 7f
    cmp x2,#' '            // space ?
    bne 3f
    add x1,x1,#1
    b   1b                 // loop 
3:
    cmp x2,#'-'            // negative ?
    bne 4f
    add x1,x1,#1
    b 5f
4:
    cmp x2,#'+'            // positive ?
    bne 5f
    add x1,x1,#1
5:
    ldrb w2,[x0,x1]        // control space
    cmp x2,#0              // end ?
    beq 7f
    cmp x2,#' '            // space ?
    bne 6f
    add x1,x1,#1
    b 5b                   // loop
6:
    ldrb w2,[x0,x1]
    cmp x2,#0              // end ?
    beq 14f
    cmp x2,#'E'            // exposant ?
    beq 9f
    cmp x2,#'e'            // exposant ?
    beq 9f
    cmp x2,#'.'            // point ?
    bne 7f
    add x3,x3,#1           // yes increment counter
    add x1,x1,#1
    b 6b                   // and loop
7:
    cmp x2,#','            // comma ?
    bne 8f
    add x3,x3,#1           // yes increment counter
    add x1,x1,#1
    b 6b                   // and loop
8:
    cmp x2,#'0'            // control digit < 0
    blt 99f
    cmp x2,#'9'            // control digit > 0
    bgt 99f
    add x1,x1,#1           // no error loop digit
    b 6b
 
9:                         // float with exposant
    add x1,x1,#1
    ldrb w2,[x0,x1]
    cmp x2,#0              // end ?
    beq 99f
 
    cmp x2,#'-'            // negative exposant ?
    bne 10f
    add x1,x1,#1
10:
    mov x4,#0              // nombre de chiffres 
11:
    ldrb w2,[x0,x1]
    cmp x2,#0              // end ?
    beq 13f
    cmp x2,#'0'            // control digit < 0
    blt 99f
    cmp x2,#'9'            // control digit > 9
    bgt 99f
    add x1,x1,#1
    add x4,x4,#1           // counter digit
    b 11b                  // and loop
 
13:
    cmp x4,#0              // number digit exposant = 0 -> error 
    beq 99f                // error
    cmp x4,#2              // number digit exposant > 2 -> error 
    bgt 99f                // error
 
    mov x0,#3              // valid float with exposant
    b 100f
14:
    cmp x3,#0
    bne 15f
    mov x0,#1              // valid integer
    b 100f
15:
    cmp x3,#1             // number of point or comma = 1 ?
    blt 100f
    bgt 99f               // error
    mov x0,#2             // valid float
    b 100f
99:
    mov x0,#0             // error
100:
    ldp x4,x5,[sp],16     // restaur  2 registres
    ldp x2,x3,[sp],16     // restaur  2 registres
    ldp x1,lr,[sp],16     // restaur  2 registres
    ret
 
/********************************************************/
/*        File Include fonctions                        */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
 
 