Re: Removing decimal points
On Jun 8, 3:52 pm, [EMAIL PROTECTED] (Ash) wrote: Hello there! I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. Did anybody mention int()? -- Brad -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
On 6/13/07, Brad Baxter [EMAIL PROTECTED] wrote: On Jun 8, 3:52 pm, [EMAIL PROTECTED] (Ash) wrote: Hello there! I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. Did anybody mention int()? -- Brad The first 6 replies were to use int(). I'm not sure about the rest. I know the 7th reply was a RegEx. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
On 6/14/07, yitzle [EMAIL PROTECTED] wrote: On 6/13/07, Brad Baxter [EMAIL PROTECTED] wrote: On Jun 8, 3:52 pm, [EMAIL PROTECTED] (Ash) wrote: Hello there! I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. Did anybody mention int()? -- Brad The first 6 replies were to use int(). I'm not sure about the rest. I know the 7th reply was a RegEx. And my second reply used split. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
Thank you all! I used POSIX floor() and ceil(). Thanks for all the suggestion. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
yitzle wrote: On 6/8/07, Xavier Noria [EMAIL PROTECTED] wrote: On Jun 8, 2007, at 9:52 PM, ash wrote: I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. Use de int() function. Why does the list attract so many duplicate responses? The list server has been down for a while, and everybody thought they were the first to answer. Please bottom-post your responses to this list. Thanks. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
On Fri, 2007-06-08 at 19:52 +, ash wrote: Hello there! I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. $i = 1.77; $j = int $i; print $j; -- Ken Foskey FOSS developer -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
ash wrote: I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. You need the int() function. perldoc -f int Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
ash 写道: Hello there! I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. is int() ok? print int(1.77); would get 1. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
On Fri, 08 Jun 2007 19:52:59 - ash [EMAIL PROTECTED] wrote: Hello there! I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. my $number = 1.77; print int $number; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
ash wrote: Hello there! I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. perldoc -f int int EXPR int Returns the integer portion of EXPR. If EXPR is omitted, uses $_. You should not use this function for rounding: one because it truncates towards 0, and two because machine representations of floating point numbers can sometimes produce counterintuitive results. For example, int(-6.725/0.025) produces -268 rather than the correct -269; that's because it's really more like -268.94315658 instead. Usually, the sprintf, printf, or the POSIX::floor and POSIX::ceil functions will serve you better than will int(). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
On 6/8/07, ash [EMAIL PROTECTED] wrote: Hello there! I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. If you just want the integer part (aka floor) then use the int function. my $n = 1.23; my $i = int $n; If you want to round to the nearest integer add 0.5 to it before using int. my $m = 1.77; my $n = 1.23; my $i = int($m+0.5); my $j = int($n+0.5); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
On 6/8/07, ash [EMAIL PROTECTED] wrote: I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. Sounds as if you're looking for int, which is documented in the perlfunc manpage. If that's not it, someone can show you how to round, floor, ceil, or whatever you need. Cheers! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
On Fri, 08 Jun 2007 19:52:59 - ash [EMAIL PROTECTED] wrote: Hello there! I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. This program removes the decimal point from your numbers #!/usr/bin/perl -w use strict; while (DATA){ chomp; my $number = $_; $number =~ s/\.//; print $number\n; } __DATA__ 1.74 2.87 3.88 __END__ Output is 174 287 388 Owen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
On Jun 8, 2007, at 9:52 PM, ash wrote: I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. Use de int() function. -- fxn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
Why does the list attract so many duplicate responses? On 6/8/07, Xavier Noria [EMAIL PROTECTED] wrote: On Jun 8, 2007, at 9:52 PM, ash wrote: I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. Use de int() function. -- fxn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Removing decimal points
On 6/9/07, yitzle [EMAIL PROTECTED] wrote: Why does the list attract so many duplicate responses? If you don't use a threading mail reader and you start with the oldest message then when you see a simple question like this that has one obviously right answer you just give it. Later you see that other people have replied, but it is too late then. At least that is why I used to do it. Now it tends to be because I am composing a reply while doing ten other things and by the time I post my message someone else has also posted it. Just to show that TIMTOWTDI my $n = 234.23234; my $i = (split '\.', $n, 2)[0]; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Removing decimal points
Hello there! I need to remove decimal points from numbers. For eg 1.23 or 1.77 would be just 1. Any suggestion is appreciated. Thank you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/