decimal point

------=_NextPart_000_0018_01C1A7FB.403BDF20
Content-Type: text/plain;
	charset="US-ASCII"
Content-Transfer-Encoding: 7bit

Hi,
I am trying to move the decimal point 2 places to the the left.
 
Eg : To make 4536233 into 45362.33
 
I tried this 
$total = "4536233";
$total = sprintf("%0.2f",$total);
print "$total";
But I get this
4536233.00
 
Can anyone help please
 
Regards
Stuart Clark
 
 
 
 
 

------=_NextPart_000_0018_01C1A7FB.403BDF20--


0
sc
1/28/2002 1:56:44 AM
perl.beginners 29378 articles. 3 followers. Follow

7 Replies
549 Views

Similar Articles

[PageSpeed] 50

use strict;
my $var=4536233;
my $new_var=$var/100;
print $new_var;

Shawn

----- Original Message ----- 
From: "Stuart Clark" <sc@spacelink.com.au>
To: "Perl List" <beginners@perl.org>
Sent: Sunday, January 27, 2002 7:56 PM
Subject: decimal point


> Hi,
> I am trying to move the decimal point 2 places to the the left.
>  
> Eg : To make 4536233 into 45362.33
>  
> I tried this 
> $total = "4536233";
> $total = sprintf("%0.2f",$total);
> print "$total";
> But I get this
> 4536233.00
>  
> Can anyone help please
>  
> Regards
> Stuart Clark
>  
>  
>  
>  
>  
> 

0
shawn
1/28/2002 7:46:53 AM
i would try dividing the number by 10

-----Original Message-----
From: Stuart Clark [mailto:sc@spacelink.com.au]
Sent: 28 January 2002 01:57
To: Perl List
Subject: decimal point


Hi,
I am trying to move the decimal point 2 places to the the left.
=20
Eg : To make 4536233 into 45362.33
=20
I tried this=20
$total =3D "4536233";
$total =3D sprintf("%0.2f",$total);
print "$total";
But I get this
4536233.00
=20
Can anyone help please
=20
Regards
Stuart Clark
=20
=20
=20
=20
=20
0
Darren
1/28/2002 8:48:14 AM
did i say 10? i meant 100

-----Original Message-----
From: Darren Simpson=20
Sent: 28 January 2002 08:48
To: 'Stuart Clark'; Perl List
Subject: RE: decimal point


i would try dividing the number by 10

-----Original Message-----
From: Stuart Clark [mailto:sc@spacelink.com.au]
Sent: 28 January 2002 01:57
To: Perl List
Subject: decimal point


Hi,
I am trying to move the decimal point 2 places to the the left.
=20
Eg : To make 4536233 into 45362.33
=20
I tried this=20
$total =3D "4536233";
$total =3D sprintf("%0.2f",$total);
print "$total";
But I get this
4536233.00
=20
Can anyone help please
=20
Regards
Stuart Clark
=20
=20
=20
=20
=20
0
Darren
1/28/2002 10:00:01 AM
Stuart Clark wrote:
> 
> Hi,

Hello,

> I am trying to move the decimal point 2 places to the the left.
> 
> Eg : To make 4536233 into 45362.33
> 
> I tried this
> $total = "4536233";
> $total = sprintf("%0.2f",$total);
> print "$total";
> But I get this
> 4536233.00
> 
> Can anyone help please

$ perl -le'
$total = 4536233; $total =~ s/(..)$/.$1/;
print $total;
$total = 4536233; substr $total, -2, 0, ".";
print $total;
'
45362.33
45362.33



John
-- 
use Perl;
program
fulfillment
0
krahnj
1/28/2002 10:28:40 AM
Try this;
my $total = "4536233";
$total =~s/(.+)(\d{2})/$1.$2/;
print $total;

----- Original Message ----- 
From: "Stuart Clark" <sc@spacelink.com.au>
To: "Perl List" <beginners@perl.org>
Sent: Sunday, January 27, 2002 5:56 PM
Subject: decimal point


> Hi,
> I am trying to move the decimal point 2 places to the the left.
>  
> Eg : To make 4536233 into 45362.33
>  
> I tried this 
> $total = "4536233";
> $total = sprintf("%0.2f",$total);
> print "$total";
> But I get this
> 4536233.00
>  
> Can anyone help please
>  
> Regards
> Stuart Clark



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

0
eventualdeath
1/29/2002 1:16:40 AM
Stuart Clark wrote:

> Hi,
> I am trying to move the decimal point 2 places to the the left.
>  
> Eg : To make 4536233 into 45362.33
>  
> I tried this 
> $total = "4536233";
> $total = sprintf("%0.2f",$total);
> print "$total";
> But I get this
> 4536233.00
>  
> Can anyone help please
>  
> Regards
> Stuart Clark


hm let me take a shot at this one

my $digits = 4536233;
$digits =~ m/(\d\d)$/;		#I was going to inline this, but not sure of return value
splice ( split ( //, $digits ), -2, 2, ( "." .  $1) ) );

that should work, probably not worth it thought (I just opened the llama 
book and picked the first function that looked good and worked from that ^.^

anyway, the reason your example didn't work is because sprintf will 
truncate decimals from a floating point number.


printf("%5.2f",$varname); 
#prints 123.12 if the var containted 123.1231525

since you had created a var containing integers (actually you created a 
string, it just turned it into numbers on demand), it didn't have 
anything to add for the decemil part.



0
sfritz31918
1/29/2002 2:04:25 AM
--part1_8e.22936f4c.2993eef3_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

In a message dated 1/28/02 1:16:55 AM Pacific Standard Time, 
perlmails@myiris.com writes:


> 

I have a sub routine that I use for making all numbers calculate to two 
decimals places which I use for calculating money values.

I will place it on my website.
The site is new and only displays well in internet explorer 5.0 and above 
till further updates.  Not as good in NetScape 6 yet. 

http://www.microwebber.com/htmlFiles/Perl/usefulSubs/decimal.html

Hope this helps!
ideas@microwebber.com
motherofperls@aol.com

--part1_8e.22936f4c.2993eef3_boundary--
0
Motherofperls
2/7/2002 5:53:39 PM
Reply:

Similar Artilces:

How to validate a decimal value with 2 digits after decimal point (de decimal point is a comma)
  I am a newbee, I have a Textbox where de user must write the price of an object. How can I validate de data entry in the Textbox (it must be a valid decimal with 2 digits after decimal point), and my pages are in  Portuguese so the decimal point to be accepted must be a comma   thanks  well you can do something like followig:  suppose TextBox1.Text = 123456,789 then you can say if(TextBox1.Text.Contains(",") ) {     int index1 = TextBox1.Text.IndexOf(",") +1;     int index2 = TextBox1.Text.IndexOf(...

Need to format float with no decimals or decimal point.
Is there a format for float that displays only the integer portion?  Or at the least, integer portion and decimal point but no digits to right? Eval("L_DistCalc", "{0:f}") Thank you, What about this: Eval("L_DistCalc", "{0:f0}")Limno Wow - thanks.  Is there a good reference book that has all the format forms, control structures and properties.  Everything I have has a the essentials but nothing in depth.  I know this kind of thing is simple but is sure is a lot to try and remember. Thank you,  You can sear...

how to convert value with decimal point into value with decimal comma
Hello,  I like to know how I can change (for example) the value 55.55 into 55,55. (The system in my country is using comma's instead of points) I'm starting with  a string with the value "55.55" Then I will convert it to a double 55,55 Do I need the the system.Globalization namespace or is there just a simple solution?               Hi,If you are just going to use this format for display then it would be easy to do this:double dTemp;dTemp = 55.55;Response.Write(dTemp.ToString().Replace(".",","));H...

Decimal point.
Hi, PB10.0 I have a problem with de decimal point: I need a comma. The problem does not appear in dw, but in edit masks. I think it's the deployment kit: I may be working with the english, not the spanish. Does anybody know which are the files? Thanks, Josep. Isn't it dependent of regional settings ? Josep pisze: > Hi, > > PB10.0 > I have a problem with de decimal point: I need a comma. > The problem does not appear in dw, but in edit masks. > > I think it's the deployment kit: I may be working with the > english, not the spa...

Decimal point
Hi guys, Is there function to get the number after a decimal point? ex: 6.500 I need to get the 500 only Thanks in advance On 27 Jun 2008 09:35:04 -0700, Ramez Nabil wrote: I think you might want to tell everyone where you get the "6.500" from e.g. numeric column etc and who you are trying to get the "500" like stored procedure, dml user, C programmer etc. I think this way you get replies that might better fit your needs. J >Hi guys, >Is there function to get the number after a decimal point? > >ex: 6.500 I need to get the 500 only &g...

XSD file Decimal column displays 4 point after decimal
Hi to all,              I have a xsd file with one table adapter, it has 4 column id int name string class string amount decimal i drag and drop the columns into rdlc file but, the report displays 4 digit after decimal point but i want to display it as two decimal point. How to do this experts please help me. But i checked in my query from sql it is displays as it is in the table(there some data have four digit after decimal some data have two digit after decimal) but when get it into DataSet object all data are converted i...

Decimal point
Hi guys, Is there function to get the number after a decimal point? ex: 6.500 I need to get the 500 only Thanks in advance Is 6.500 a number or string? Do all 'numbers' have 3 places to the right of the decimal point, eg, could you have numbers like 3.45, 285.38492? And if you can have less/more than 3 digits, what would you expect as the final result? And does the final result need to be a number or string? Ramez Nabil wrote: > Hi guys, > Is there function to get the number after a decimal point? > > ex: 6.500 I need to get the 500 only > &g...

mailSession and decimal point
Hello all, I'm having this problem: After executing de mailLogon() in mailSession i kan not use decimals anymore in the application. I have a ',' as decimal symbol. Having a . as decimal symbol works fine. Any ideas? thanks, Carlos Oh... and i'm using Powerbuilder 5.0.04 Never mind. I solved de problem by setting the decimal en thousand symbols to '.' en ',' (american defaults) in de registry and when i am ready with de mailSession object put de old values back again. The problem is not realy solved but this workaround seams to work...

decimal point #2
------=_NextPart_000_001D_01C1A834.21827C90 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Hi, I am trying to move the decimal point 2 places to the the left. Eg : To make 4536233 into 45362.33 I tried this $total = "4536233"; $total = sprintf("%0.2f",$total); print "$total"; But I get this 4536233.00 Can anyone help please Regards Stuart Clark ------=_NextPart_000_001D_01C1A834.21827C90-- Dear Stuart, The Sprintf function may not be able to change the value of the scalar varia...

How to remove the decimal point ?
A simple question.I am working with asp.net c# and I a have a variable with .00 (ex: 500.00).I would like to convert this variable to 500Bottom line: to remove the .00Someone know what do I have to write ? Try:FormatNumber(Myvariable, 0)--------------------------------------------------------Don't forget to click "Mark as Answer" on the post(s) that helped you.NHibernate with ASP.net Problem-Design-Solution sample applicationScott ASP.net blog  This is working  TextBox1.Text = String.Format("{0:0.##}", 123.00);   Mark as Answer if the p...

Decimal point / comma
Hi, We have been stuggeling for some time with a decimal point issue on our windows 2000 workstation. On a em (or dw column) we use an editmask of "#0.00" or "##.00" the em shows 0.00 or .00 during runtime. If we enter 12.15 we get 1215 if we show dec(em.text) in a messagebox. If we change the country for Dutch/Belgium to English/Us, the program works correct, but when we change it back, the problem popsup again. We use powerbuilde 8 build 9100 Andrew Peiman May be you can use String() function with format Messagebox( "Message", String(d...

Decimal point and comma
Hi, I have this problem validating a powerbuilder exported XML file versus and XSD using the XMLParseFile function. I get the following error: Error parsing XML document: Datatype error: Type:InvalidDatatypeValueException, Message:Value '1,00' does not match any member types (of the union) . d:\interfaces\stockmove\out\S17.C2P, Line: 17, Position: 24. The tag in question looks as follows: <qtyVal>1,00</qtyVal> The problem seems to be that a numeric field ( which is part of a union in the XSD because I need it to allow empty values, which can&...

Decimal points in datawindows
I am having a problem with decimals in my datawindows. When I try entering a percentage value, it is abandoning all values to the right of the decimal. Incidentally, the field is a decimal with no validation. Edit Mask: Format: Input: Result: None (General) 3.2 3 None (General) 0.032 0 None (General) 3.2% "Does not pass validation" None 0.00% 3.2 300.00% None ...

dropping off a few decimal points
okay... so how do I drop of all but two decimal points in perl? __________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/ One way to do it ... perl -e '$x=1234.5678; ($y)=$x=~/(\d*\.{0,1}\d{0,2})/;print $y ."\n";' -----Original Message----- From: Thomas Jakub [mailto:rrhspub@yahoo.com] Sent: July 10, 2001 15:44 To: beginners-cgi@perl.org Subject: dropping off a few decimal points okay... so how do I drop of all but two decimal points in perl? _____________...

Web resources about - decimal point - perl.beginners

Decimal representation - Wikipedia, the free encyclopedia
Proof: Let , where . Then , and the result follows from dividing all sides by . (The fact that has a finite decimal representation is easily ...

Dewey Decimal Classification - Wikipedia, the free encyclopedia
This highly organized system categorizes books on library shelves in an efficient, specific and repeatable order that makes it easy to find any ...

Fraction Calculator + Decimals to Fractions Converter on the App Store on iTunes
Get Fraction Calculator + Decimals to Fractions Converter on the App Store. See screenshots and ratings, and read customer reviews.

Dewey Decimal Tattoo - Flickr - Photo Sharing!
Children's librarians represent.

Math of the Day: Sesame Street’s The Count Reads Pi to 10,000 Decimal Places
... has created a true monster out of your favorite Sesame Street vampire, with audio of The Count reading every digit of Pi out 10,000 decimal ...

UPDATED: Paul Harapin heads Decimal Software as CEO
Former VCE Asia-Pacific boss, Paul Harapin, has confirmed he is the new chief executive officer (CEO) of Decimal Software.

Feeling green: the dangers of decimal currency
The curious case of possibly toxic coins, via Austria and a devastatingly original idea for Canberra.

Jobless Rates With Another Decimal
The BLS reported a jobless rate of 8.3% for both January and February. Adding an extra decimal, the unemployment rates would actually be 8.26% ...

JPMorgan Sued by Trader Over $3 Million Decimal Point
JPMorgan Chase & Co. is being sued by a trader who says he accepted a contract from the investment bank because a typographical error made him ...

.Decimal Archive - Houston Gamer
It was only back in August when newly-formed Houston game studio Orb Interactive launched a Kickstarter campaign for “.Decimal”, a sci-fi take ...

Resources last updated: 1/6/2016 10:20:09 AM