Greetings,
I'm running the ported mawk version 1.3.3 under Win 2K Pro, and am getting the fatal error message:
"(Source) Line nnn: Return outside function body."
for all functions with a "return" statement. Strangely, I don't get any errors when interpreting the exact same code with awk95.exe and gawk.exe.
Can you determine what is wrong?
Thanks,
-Bob
Sample code:
###################################################
func qword_to_double (qword, mantissa, exponent) {
###################################################
ifunc++;
#Convert a quadruple hex word (64 bit) value to double
#precision IEEE floating point.
#First, convert to binary
qwordbin = hex2bin(qword);
#Extract sign bit
sgn = substr(dwordbin, 1, 1) == "1" ? -1 : 1;
#Extract exponent
exponent = bin2uint( substr(qwordbin, 2, 11) );
#Extract mantissa
mantissa = bin2uint( substr(qwordbin, 13, 52) ) / 2^52;
#print "Hex to Double:\t", qword "\s", qwordbin "\s", length(qwordbin) "\s", sgn "\s", expbin "\s", mantbin "\s", exponent "\s", mantissa "\n" > "DPDiag.txt";
#Put it all together and return ...
return (sgn * 2^(exponent - 1023) * (1.0 + mantissa) );
}
I'm running the ported mawk version 1.3.3 under Win 2K Pro, and am getting the fatal error message:
"(Source) Line nnn: Return outside function body."
for all functions with a "return" statement. Strangely, I don't get any errors when interpreting the exact same code with awk95.exe and gawk.exe.
Can you determine what is wrong?
Thanks,
-Bob
Sample code:
###################################################
func qword_to_double (qword, mantissa, exponent) {
###################################################
ifunc++;
#Convert a quadruple hex word (64 bit) value to double
#precision IEEE floating point.
#First, convert to binary
qwordbin = hex2bin(qword);
#Extract sign bit
sgn = substr(dwordbin, 1, 1) == "1" ? -1 : 1;
#Extract exponent
exponent = bin2uint( substr(qwordbin, 2, 11) );
#Extract mantissa
mantissa = bin2uint( substr(qwordbin, 13, 52) ) / 2^52;
#print "Hex to Double:\t", qword "\s", qwordbin "\s", length(qwordbin) "\s", sgn "\s", expbin "\s", mantbin "\s", exponent "\s", mantissa "\n" > "DPDiag.txt";
#Put it all together and return ...
return (sgn * 2^(exponent - 1023) * (1.0 + mantissa) );
}