ccz80

Would you like to react to this message? Create an account in a few clicks or log in to continue.
ccz80

ccz80 programming language


2 posters

    output nummero without zero .

    avatar
    funkheld


    Posts : 51
    Join date : 2009-12-16
    Age : 75
    Location : germany, lüneburg

    output nummero without zero . Empty output nummero without zero .

    Post  funkheld Fri Jan 08, 2010 3:13 am

    left justified without zero !

    input > 200.123
    output > with zero -0000400.246
    without zero > -400.246


    gruss

    Code:

    include "cpc6128.ccz80";

    array byte text[12];
    array byte a[5];
    array byte b[5];
    byte n,i,z,d;

    input(text);
    atof(a,text);

    mul(a,atof(b,"-2.0"));

    ftoa(text,a);
    prints("\r\n");
    prints(text);

    prints("\r\n");

    d=0;
    if (*(text)=='-')
    {
       prints("-");
       d=1;
    }

    for (i =d; i <= 6; ++i)
    {
     n=*(text+i);
     if (n>48) goto weiter;
    }
    weiter:
    for (z =i; z <= 11; ++z)
    {
     n=*(text+z);
     printc(n);
    }

    return;
    avatar
    Dinoneno


    Posts : 115
    Join date : 2008-01-15
    Age : 53
    Location : Toledo

    output nummero without zero . Empty Re: output nummero without zero .

    Post  Dinoneno Fri Jan 08, 2010 4:24 am

    Well work, but you can write this program so:

    Code:
    include "cpc6128.ccz80";

    string text[12];
    array byte a[5], b[5];

    input(text);
    atof(a,text);

    mul(a,atof(b,"-2.0"));

    ftoa(text,a);
    prints("\r\n");
    prints(text);
    prints("\r\n");

    prints(strltrm(text + (*text == '-'), '0'));
    return;

    Remarks:
    - All relational expressions (with comparision operators, return 1 if true or 0 if false). We can use this for get 0 or 1 easily.
    - The function strltrm remove, from the string as 1st parameter, the character specified as 2nd parameter until another character is found. Example: the expression strltrm("aaaaabbccaaa", 'a') remove the first 5 letters and returns the address from string "bbccaaa".
    - For any expression that use a string, if we specify the string name, we use the string from begin, if we specify string + n, we use the string that starts in address of string + n characters.

    This is as an hieroglyphic game for know as work an instruction Very Happy.
    avatar
    funkheld


    Posts : 51
    Join date : 2009-12-16
    Age : 75
    Location : germany, lüneburg

    output nummero without zero . Empty Re: output nummero without zero .

    Post  funkheld Fri Jan 08, 2010 4:50 am

    mul(a,atof(b,"-2.0"));

    input "123.123" not result print "-246.246" the print "246,246", it is not ok.


    gruss
    avatar
    Dinoneno


    Posts : 115
    Join date : 2008-01-15
    Age : 53
    Location : Toledo

    output nummero without zero . Empty Re: output nummero without zero .

    Post  Dinoneno Fri Jan 08, 2010 5:10 am

    Sorry Razz, lack this instruction before prints(strltrm ...):

    if (*text == '-') printc('-');

    It's much like your idea, which is the same as strltmb ago.
    avatar
    funkheld


    Posts : 51
    Join date : 2009-12-16
    Age : 75
    Location : germany, lüneburg

    output nummero without zero . Empty Re: output nummero without zero .

    Post  funkheld Fri Jan 08, 2010 5:34 am

    whery got.
    thanks.

    why can in the asm-routine ?
    Code:

    if (*text == '-') printc('-');
    prints(strltrm(text + (*text == '-'), '0'));

    Sponsored content


    output nummero without zero . Empty Re: output nummero without zero .

    Post  Sponsored content


      Current date/time is Sat Apr 20, 2024 1:16 am