Re: coding help

2016-03-01 Thread Shawn H Corey
On Tue, 1 Mar 2016 12:05:14 +0530 Arghya Das wrote: > $num = 1234; > $sum = 0; > > while ( $num != 0) > { > $rem = $num % 10; > $sum = ( $sum * 10 ) + $rem; > $num = $num / 10; $num = int( $num / 10 ); > } > > print $sum; > > > > please tell what is wrong with the reverse number code .

Re: coding help

2016-02-29 Thread Kent Fredric
On 1 March 2016 at 19:35, Arghya Das wrote: > $num = 1234; > $sum = 0; > > while ( $num != 0) > { > $rem = $num % 10; > $sum = ( $sum * 10 ) + $rem; > $num = $num / 10; > } > > print $sum; I suspect you're just exceeding precision limits. Modified code: use strict; use warnings; my $num = 1234