c# - Convert from hexadecimal to float -
i have string array has hexadecimal values in it. want convert float array. tried code below doesn't give me correct results:
bufferarray
string array contains hexadecimal values.
float[] dblbffrarry = new float[bufferarray.length]; (int = 0; < bufferarray.length; i++) { long parsed = long.parse(bufferarray[i], numberstyles.allowhexspecifier); dblbffrarry[i] = parsed; }
can point way it?
maybe like:
float[] floatbffrarry = bufferarray.select(s => convert.toint64(s, 16)) .select(i => (float)i).toarray();
edit:
a different interpretation of ask is:
float[] floatbffrarry6 = bufferarray.select(s => convert.touint64(s, 16)) .select(i => bitconverter.tosingle(bitconverter.getbytes(i), 0)).toarray();
it's hard know want when don't give examples of inputs , outputs.
for both examples, of course there's no need have .select
after each other; can 1 .select
if substitute 1 lambda arrow =>
other.
Comments
Post a Comment