Problems Printing Integers

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
M@rtyn12345

Problems Printing Integers

Post by M@rtyn12345 »

[attachment deleted by admin]
Tim

Re:Problems Printing Integers

Post by Tim »

What's this "%i" format? Use "%d" to print Decimal integers.
M@rtyn12345

Re:Problems Printing Integers

Post by M@rtyn12345 »

it's a self-made printf function and I didn't write the routine for %d, but I tried to write a routine for the %i argument. I doesn't work, so I asked for help.
Tom

Re:Problems Printing Integers

Post by Tom »

I have a working printf with ints, hex...and all the other stuff.

Tell me if that works....

It is in pk0.7.1
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Problems Printing Integers

Post by Pype.Clicker »

This works! But now here's the problem. If I want to print the integer value zero ("0") it prints nothing (NULL?).
that doesn't astonish me as you have some "if (i==0) break;" ... probably mainly because of the recursive behaviour of the function ;-)
And integer values higher than 127 are printed in characters. For example, 128 prints "/.(" (without the quotes)
i think this is because "ch" is declared as a char rather than as an unsigned char and then casted to a unsigned ... this might give weird results from the " ch % 10" function ... (i mean negative values) that would be badly interpreted ...

btw, why do you restrict %i to chars ? why not dealing with full-sized integers ?
Tom

Re:Problems Printing Integers

Post by Tom »

Well...My old printf was not all that wonderful...it worked....but did extra things that it didn't have to ( it checked the type of \'s...but putch does that...I forgot to remove it in the release. )

I think you should use the pk0.7.1 printf.
M@rtyn12345

Re:Problems Printing Integers

Post by M@rtyn12345 »

OK, but where did you post it? Your page's index.html is not online.
Tom

Re:Problems Printing Integers

Post by Tom »

Having problems with SF

working link:
www.sourceforge.net/projects/fritzos
Post Reply