in reply to Re: porting C code to Perl
in thread porting C code to Perl
> Perl's int is not the same as C's floor()..
I already admitted my superb ignorance but i read here that in C floor turns 1.6 1.2 2.8 2.3 into 1 1 2 2 or simply 'This function returns the largest integral value not greater than x'.
This is identical to the int function where any decimal are stripped out: say int $_ for qw(1.6 1.2 2.8 2.3)
> Perl has a pre-decrement just like C..
I have meditated a bit over this before trying to port the code and, sincerely I didnt read the C documents about post and pre increment, but as I have always understood the third part of the Perl's C style for loop is a statement on it's own: ie ++$var; or $var++; are identical.
Infact for($i=0;$i<4;$i++){say $i} and for($i=0;$i<4;++$i){say $i} produce the very same, expectable results. Switching between them in the above code does not change the result.
L*
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: porting C code to Perl (updated)
by haukex (Archbishop) on Oct 23, 2017 at 20:08 UTC | |
|
Re^3: porting C code to Perl
by soonix (Chancellor) on Oct 23, 2017 at 20:31 UTC |