News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

64bit atoqw or qwtoa in any library

Started by K_F, May 19, 2015, 09:26:38 PM

Previous topic - Next topic

jj2007

Quote from: K_F on May 21, 2015, 04:46:05 AMBatch processing a whole lot of string numbers (reading a large data file full of integer number strings)

How big? Can you post an example file? It could be a candidate for StringToArray():

include \masm32\MasmBasic\MasmBasic.inc      ; download
.data
txtData      db "12.34 56.78 90.12 34.56 78.90 12.34 $FF", 13, 10
      db "-12.34 -56.78 -90.12 -34.56 -78.90 -12.34 0xFF 1111b 1.234e56", 0      ; see Val

  Init
  Dim MyData() As REAL8      ; could also be WORD, DWORD, QWORD, REAL4, REAL10
  StringToArray offset txtData, MyData()      ; do the conversion from text to binary
  For_ ecx=0 To eax
      Print Str$("%i\t", ecx), Str$("%4f\n", MyData(ecx))
  Next
  Inkey Str$("%i elements found", ecx)
  Exit
end start


Output:
0       12.34
1       56.78
2       90.12
3       34.56
4       78.90
5       12.34
6       255.0
7       -12.34
8       -56.78
9       -90.12
10      -34.56
11      -78.90
12      -12.34
13      255.0
14      15.00
15      1.234e+56
16 elements found


P.S.: StringToArray FileRead$("Data.txt"), MyData() is also valid syntax.

K_F

Quote from: jj2007 on May 21, 2015, 06:55:25 AM
Quote from: K_F on May 21, 2015, 04:46:05 AMBatch processing a whole lot of string numbers (reading a large data file full of integer number strings)
How big?
I'm thinking of anywhere from 1K to 64Ks worth of just numbers
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

jj2007

64k will take about one millisecond with StringToArray.

K_F

Interesting...Is StringToArray available for perusal  :biggrin:

I might add that I'm looking at converting to/from a text file, (un)signed integers 8/16/32/64bits and floats (Real-4/8&10)
:t
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

jj2007

Sure, just install MB, the link is below.

include \masm32\MasmBasic\MasmBasic.inc      ; download
  Init
  Dim MyData() As REAL8      ; could also be WORD, DWORD, QWORD, REAL4, REAL10
  StringToArray FileRead$("DataBig.txt"), MyData(), staHasText
  For_ ecx=0 To eax
      .if !(ecx & 15)
            Print Str$("\n%__i\t", ecx)
      .endif
      Print Str$("%4f\t", MyData(ecx))
  Next
  Inkey Str$("\n%i elements found", ecx)
  Exit
end start

dedndave

i don't think that's what he meant - lol