I have a four byte string read from a binary file that should represent an integer. How can I stop an integer?
Example:
my $s = '\xa8e2~'; my $i = stoi($s); printf "%X", $i; #gives "0x7e3265a8"
The solution in C is simple:
fread(&i,4,1,fp);
$i = unpack("s", $s) may work, but it depends on the subscription order / unsigned and byte, so you will probably find yourself here: http://perldoc.perl.org/perlpacktut.html#Integers
$i = unpack("s", $s)
Look at the unpack function
unpack
Source: https://habr.com/ru/post/1332276/More articles:FBConnect: Facebook authentication screen does not redirect to my application - iphoneSQL Server 2008: what is lazy schema validation? - sql-server-2008Updating a column with its current value - optimizationC ++: sowing random number generator outside the main () - c ++Paypal button code for automatic redirection after payment - paypalresignFirstResponder does not work in modular view controller - iosComponent Socket Delphi - delphiC ++ get the last (n) char in a string - c ++Oracle - in CLAUSE question when used with multiple values, making it dynamic - oracleJava error: printf - javaAll Articles