floating poins in perl 
Author Message
 floating poins in perl

Hi

How can I force a value like 8.9 to apear or print on the
screen as double or float value like 8.90 without using
printf function

My point is to print

$value=8.9;
$order=<<MOO
$value
MOO

on the screen as 8.90

if there is a way a can do it please email me.

Thanks

Abukar



Sat, 28 Jul 2001 03:00:00 GMT  
 floating poins in perl
: Hi
:
: How can I force a value like 8.9 to apear or print on the
: screen as double or float value like 8.90 without using
: printf function
:
: My point is to print
:
: $value=8.9;
: $order=<<MOO
: $value
: MOO
:
: on the screen as 8.90
:
: if there is a way a can do it please email me.
:
: Thanks
:
: Abukar
:
:

        Is "sprintf" what you're looking for?

$value=8.9;
$order=sprintf('%.2f',$value);
print <<MOO
$order
MOO

__END__

Jim Turner



Tue, 31 Jul 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. String Float to Machine Float

2. Perl's brain-dead floating point math

3. Perl floating point okay to represent $ amounts?

4. floats and endian-ness in perl

5. Perl bug (Floating exception)

6. Handling floating point number input in Perl CGI scripts

7. Perl 5.001e *** Floating point exception

8. Problem compiling perl with software floating point emulation

9. Perl floating point problem

10. Floating points in Perl

11. perl floating points

12. help with floats in calling C from perl

 

 
Powered by phpBB® Forum Software