1. Printf Problem

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

new topic     » topic index » view message » categorize

2. Re: Printf Problem

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: Printf Problem

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... }}}

new topic     » goto parent     » topic index » view message » categorize

4. Re: Printf Problem

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"

new topic     » goto parent     » topic index » view message » categorize

5. Re: Printf Problem

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

new topic     » goto parent     » topic index » view message » categorize

6. Re: Printf Problem

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

new topic     » goto parent     » topic index » view message » categorize

7. Re: Printf Problem

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?

new topic     » goto parent     » topic index » view message » categorize

8. Re: Printf Problem

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/

new topic     » goto parent     » topic index » view message » categorize

9. Re: Printf Problem

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

new topic     » goto parent     » topic index » view message » categorize

10. Re: Printf Problem

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"

new topic     » goto parent     » topic index » view message » categorize

11. Re: Printf Problem

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

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu