Announcement

Collapse
No announcement yet.

Number formatting

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • yuck
    replied


    oki, so there is a real problem and not just something that I did wrong. thank you

    Leave a comment:


  • meldavia
    replied


    yes I see now,

    only thing to suggest for a fix is to make a wrapper for putnum or print, eg

    func fnum(var num)
    if(!(num&0x8000)) putch(' ');
    putnum(DEC5, num);
    endfunc

    Leave a comment:


  • yuck
    replied

    giving this example:

    Code:
    #platform "uLCD-32PT_GFX2"
    
    func main()
    var val1 := 5;
    var val2 := -5;
    
    print([0b1011001000001010] val1, " \n");
    print([0b1011001000001010] val2);
    
    repeat forever
    endfunc;
    i would expect the result to be: "__5 \n -_5" (where _ stands for space, \n for newline of course) Instead i get "_5 \n -_5"

    problem is that i can't print a variable going from negative to positive without shifting text on the display. i lived with the impression that bit 15 of the formatting constant will add a space for signed variables that hold a positive value, and replace that space with - (minus) when the variable holds a negative value, thus keeping the display same width (character wise)

    hope I was more clear now, thank you

    Leave a comment:


  • meldavia
    replied


    not fully understanding what your trying to do
    if you think this might be a bug, a little code example would be appreciated

    Leave a comment:


  • yuck
    started a topic Number formatting

    Number formatting

    I want to display a signed number with a fixed representation, like [sign][digit1][digit2]

    If sign is positive I want a space instead, if digit 1 is 0 i want a space instead.

    The number formatting constant needed for putnum/print functions should be 0b1011_0010_000_01010 (underscores added for readability) as far as I can tell.

    Problem is that bit 15 (space before unsigned number) doesn't seem to work no matter how I use it.

    Help anyone?
Working...
X