On 21 Okt, 14:52, jian...@gmail.com (Majian) wrote: > Hi, all ; > > I want to print this sentence " The number in scientific > notation is 1.255000e+02". > > So I write a perl script like this : > #!/usr/bin/perl > sprintf "The number in scientific notation is %e", 1.255; > But the screen output is "The number in scientific notation is > 1.255000e+00" > > And I modify it like this "sprintf "The number in scientific > notation is %e", 01.255;" > The screen now output is " The number in scientific notation > is 1.255000e+03" > > I don't know how I can display the correct answer . > > Please forgive me if this is a very simple question on Perl . I am a > Perl newbie ~~~ > > Thanks ~~~
#!/usr/bin/perl printf("The number in scientific notation is %e\n", 125.55); Gives The number in scientific notation is 1.255500e+002 I test to enter the result you are looking for as perl -42 de now ju can test single line of Perl kode heter i enter print 1.255500e+02 ( CTRL-Z) takes you out, (att least in WIndows version of PERL) You can read more about formating data in this link http://perldoc.perl.org/functions/sprintf.html Best regards Anders -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/