Native number Syntax: 0xFF, 0b1011,...

Idea created by mrwatson-gbs on May 29, 2018
    Active
    Score7
    • user19752
    • ThierryGuemboura
    • Hemant Kumar Patel
    • monkeybreadsoftware
    • mrwatson-gbs
    • TorstenBernhard
    • davidsan

    Idea

     

    The calculation engine should be extended to support common syntaxes for numbers in alternative bases, for example - in order of importance (at least, as perceived by myself ):

     

    1. Hexadecimal numbers starting with 0x, thus 0xFF represents 255
    2. Binary numbers starting with 0b, thus 0b1111 represents 15
    3. Octal numbers starting with 0o… (or just 0123?)

     

     

    Benefits

     

    • Common and well-known number syntaxes could be entered anywhere in the calc. engine where Hex, Binary or Octal numbers are needed.
    • It would be easier to handle colors
    • It would be easier to process DDR and FileMaker (Clipboard) XML
    • Code would be more readable.
    • Code would be more sharable + compatible
    • XML + DDR (flags) would be easier to analyse + construct
    • => Less errors / Higher quality databases

     

    Use Cases

    • Defining Colors
      • TextColor ( "pink" ; RGB( 0xFF ; 0x80 ; 0x80 ) )
      • TextColor ( "pink" ; 0xFF8080 )
      • Evaluate( "0x" & $CssColor ) // Converts "FF8080" o the decimal
    • Characters
      • Char( 0x2588 ) // 'Full Block' "█" - Note: Already possible, but with UTF-8 bytes: HexDecode( "E29688" )
      • Char( 0xFFFE ) // UTF-16 BOM
      • Char( 0x2460 + $n - 1) // Circled digit $n
    • Processing [DDR] Flags
      • If [ Mod ( Div ( $FieldObjFlags ; 0x0020 ) ; 2 ) /* Exit field on TAB key */ ]
      • If [ Mod ( Div ( $FieldObjFlags ; 0b100000 ) ; 2 ) /* Bit 6 set */ ]
      • Set Variable [ $Flags ; cf_LogicalXOR( $Flags ; 0b10000000 ) /* Toggle bit 8 */ ]
    • etc.