by Carlos Mora » Wed Feb 24, 2016 2:50 pm
Don't know about xHarbour, but probably this is sth related to the numeric type used by nExtMem() an xHabour's integers. Using a 4 byte UNSIGNED LONG we can represent integers from 0 to 256^4-1, or 4,294,967,295, or SIGNED, ranging from -2,147,483,647 TO 2,147,483,648. I think the function is working fine, but returning an UNSIGNED LONG that xHarbour is handling as signed, so that's why you ar getting negative results. A quick temporary patch can be that, in case of a negative result, it should be substracted from 256^4-1, wich will result in your case to 3840 Mb, that is your claimd free mem.
Obvously, this patch will fail in PC with more than 4 GB, as probably will do anything in 32 bits with results expresing byte counts that a 4 byte LONG won't be able to represent.