1. Printf Problem
- Posted by David Mosley <davidmosley at davesjigsaw.com> Mar 03, 2005
- 586 views
Hi I have a problem with printf I need to get this output 1.000.00 I have tired this printf(1,"%d 5.2",exp[y]) but I keep get the wrong output can someone help me thanks also does anyone have a function that uses a format like this printusing(#.###.##) that would be easer to understand thanks. David Mosley webmaster at davesjigsaw.com
2. Re: Printf Problem
- Posted by Jonas Temple <jtemple at yhti.net> Mar 03, 2005
- 542 views
David Mosley wrote: > > Hi > I have a problem with printf I need to get this output > 1.000.00 > I have tired this > printf(1,"%d 5.2",exp[y]) > but I keep get the wrong output can someone help me thanks > also does anyone have a function that uses a format like this > printusing(#.###.##) > that would be easer to understand thanks. > David, I'm a little confused. Why would you want to take a numeric variable and insert two decimal places? If I had to guess, it's probably not a number, right? Is it more of an id or some code, such as an item number or account number. Here's a thought: if you number had three parts (#.###.##) and this is the format that it should always be displayed in, why not try:
sequence code code = sprintf("%d",exp[1]) & "." & sprintf("%d",exp[2]) & "." & sprintf("%d", exp[3])
So in other words, you would split your "number" into three seperate sections. Clear as mud? Jonas Temple http://www.yhti.net/~jktemple
3. Re: Printf Problem
- Posted by Mario Steele <eumario at trilake.net> Mar 03, 2005
- 585 views
Jonas Temple wrote: > > David Mosley wrote: > > > > Hi > > I have a problem with printf I need to get this output > > 1.000.00 > > I have tired this > > printf(1,"%d 5.2",exp[y]) > > but I keep get the wrong output can someone help me thanks > > also does anyone have a function that uses a format like this > > printusing(#.###.##) > > that would be easer to understand thanks. > > > David, > I'm a little confused. Why would you want to take a numeric variable and > insert two decimal places? > > If I had to guess, it's probably not a number, right? Is it more of an id > or some code, such as an item number or account number. Here's a thought: > if you number had three parts (#.###.##) and this is the format that it > should always be displayed in, why not try: > > }}} <eucode> > sequence code > code = sprintf("%d",exp[1]) & "." & sprintf("%d",exp[2]) & "." & sprintf("%d", > exp[3]) > </eucode> {{{ actually, it would be more like....
sequence code code = sprintf("%d",exp[1]) & "." & sprintf("%0.3d",exp[2]) & "." & sprintf("%0.2d", exp[3])
This would allow for the first section to be how-ever big, the second section to atleast have 3 0's in it, if the number isn't high enough to take up 3 characters (Such as '0'), and the same applies to the third section, only it reduces the number to 2 characters.
Hope this help's out some as well.
Mario Steele http://enchantedblade.trilake.net Attaining World Dominiation, one byte at a time... }}}
4. Re: Printf Problem
- Posted by Al Getz <Xaxo at aol.com> Mar 03, 2005
- 541 views
Hi David, Jonas, and Mario, I was going to ask what format his exp[y] was in... whole number, float, sequence, etc. Take care, Al And, good luck with your Euphoria programming! My bumper sticker: "I brake for LED's"
5. Re: Printf Problem
- Posted by David Guy <gad at cloud9.net> Mar 03, 2005
- 571 views
- Last edited Mar 04, 2005
Jonas Temple wrote: > > David Mosley wrote: > > > > Hi > > I have a problem with printf I need to get this output > > 1.000.00 > > > David, > > I'm a little confused. Why would you want to take a numeric variable and > insert two decimal places? IIANM, in Europe periods are used in place of commas when writing numbers, so 1,000.00 would be written as 1.000.00 DGuy
6. Re: Printf Problem
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Mar 03, 2005
- 570 views
- Last edited Mar 04, 2005
David Guy wrote: > > > David Mosley wrote: > > > > > > Hi > > > I have a problem with printf I need to get this output > > > 1.000.00 > > IIANM, in Europe periods are used in place of commas when writing numbers, > so 1,000.00 would be written as 1.000.00 Actually, it would probably be 1.000,00. The real question, as others have alluded to, what is the value of the data being formatted, and what does the format mean? Matt Lewis
7. Re: Printf Problem
- Posted by Andy Serpa <ac at onehorseshy.com> Mar 03, 2005
- 602 views
- Last edited Mar 04, 2005
Mario Steele wrote: > > actually, it would be more like.... > }}} <eucode> > sequence code > code = sprintf("%d",exp[1]) & "." & sprintf("%0.3d",exp[2]) & "." & > sprintf("%0.2d", exp[3]) > > Actually, this too could be simplified: code = sprintf("%d.%0.3d.%0.2d",exp) -- assumes exp is a 3-element sequence Of course, if exp is actually an atom, which it probably is, then I have the same questions as the others -- what exactly are you trying to do?
8. Re: Printf Problem
- Posted by Chris Burch <chriscrylex at aol.com> Mar 03, 2005
- 529 views
- Last edited Mar 04, 2005
David Guy wrote: > > Jonas Temple wrote: > > > > David Mosley wrote: > > > > > > Hi > > > I have a problem with printf I need to get this output > > > 1.000.00 > > > > > David, > > > > I'm a little confused. Why would you want to take a numeric variable and > > insert two decimal places? > > IIANM, in Europe periods are used in place of commas when writing numbers, > so 1,000.00 would be written as 1.000.00 > > DGuy > Not in the UK Chris http://members.aol.com/chriscrylex/euphoria.htm http://uboard.proboards32.com/
9. Re: Printf Problem
- Posted by David Mosley <davidmosley at davesjigsaw.com> Mar 03, 2005
- 559 views
- Last edited Mar 04, 2005
Hi Ok this is what I am writing a program to do my budget,so What I need to know is what the %d 8.2 means the printusing thing is from basic all it does is take the result say 40 and makes it look like 40.00 right now when i use this %d I get ouput like this 40 I would like the .00 after that.I hope this clears up things Thanks for the help PS I tried to read the docs on printf but it does not make any sence to me I was bad at math when I was a kid,that is why I started programing LOL David Mosley webmaster at davesjigsaw.com
10. Re: Printf Problem
- Posted by Al Getz <Xaxo at aol.com> Mar 04, 2005
- 540 views
Hi dave, Try this: --------------------------- include misc.e printf(1,"%8.02f\n",40) sleep(90) --------------------------- Take care, Al And, good luck with your Euphoria programming! My bumper sticker: "I brake for LED's"
11. Re: Printf Problem
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Mar 07, 2005
- 576 views
On Thu, 03 Mar 2005 08:43:11 -0800, David Mosley <guest at RapidEuphoria.com> wrote: >Hi >I have a problem with printf I need to get this output >1.000.00 I have a financial formatting routine which will handle this: http://palacebuilders.pwp.blueyonder.co.uk/effmt.html You can get the above output using: puts(1,ffmt(1000,".0.2")) or puts(1,ffmt(1000,"..2")) where the format string (".0.2") is: <no currency symbol> <use '.' as thousands separator> <field width of 0: no zero-fill, return unjustified> <decimal separator is '.'> <print 2 decimal places> <no thousands/millions indicator> <no special credit/debit indicator> Regards, Pete