SQLite

Check-in [4b86ccdf4f]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Casting hex literals directly from string to float always results in a positive number.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | hex-literal
Files: files | file ages | folders
SHA1: 4b86ccdf4f4eb4339a5706e10ad24f01b6c3939e
User & Date: drh 2014-07-23 02:07:11.054
Context
2014-07-23
13:40
Change the hex literal processing so that only the SQL parser understands hex literals. Casting and coercing string literals into numeric values does not understand hexadecimal integers. This preserves backwards compatibility. Also: Throw an error on any hex literal that is too big to fit into 64 bits. (check-in: 6c6f0de59b user: drh tags: hex-literal)
02:07
Casting hex literals directly from string to float always results in a positive number. (check-in: 4b86ccdf4f user: drh tags: hex-literal)
01:59
Reformatting a few test cases for clarity. (check-in: 7e1bbacb11 user: drh tags: hex-literal)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/hexlit.test.
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
hexlit1 216 0x00D 13
hexlit1 217 0x00e 14
hexlit1 218 0x00E 14 
hexlit1 219 0x00f 15
hexlit1 220 0x00F 15

proc hexlit2 {tnum hex ans} {
  do_execsql_test hexlit-$tnum "SELECT printf('%7e',CAST($hex AS real))" $ans
}

hexlit2 300 0x1 1.000000e+00
hexlit2 301 0x10 1.600000e+01
hexlit2 302 0x100 2.560000e+02
hexlit2 303 0x1000 4.096000e+03
hexlit2 304 0x10000 6.553600e+04







|







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
hexlit1 216 0x00D 13
hexlit1 217 0x00e 14
hexlit1 218 0x00E 14 
hexlit1 219 0x00f 15
hexlit1 220 0x00F 15

proc hexlit2 {tnum hex ans} {
  do_execsql_test hexlit-$tnum "SELECT printf('%7e',CAST('$hex' AS real))" $ans
}

hexlit2 300 0x1 1.000000e+00
hexlit2 301 0x10 1.600000e+01
hexlit2 302 0x100 2.560000e+02
hexlit2 303 0x1000 4.096000e+03
hexlit2 304 0x10000 6.553600e+04
138
139
140
141
142
143
144
145
146
147
148
149
150
hexlit2 324 0x1000000000000000000000000 7.922816e+28
hexlit2 325 0x10000000000000000000000000 1.267651e+30
hexlit2 326 0x100000000000000000000000000 2.028241e+31
hexlit2 327 0x1000000000000000000000000000 3.245186e+32
hexlit2 328 0x10000000000000000000000000000 5.192297e+33
hexlit2 329 0x100000000000000000000000000000 8.307675e+34

hexlit2 400 0x07fffffffffffffff  9.223372e+18
hexlit2 401 0x08000000000000000 -9.223372e+18
hexlit2 402 0x0ffffffffffffffff -1.000000e+00
hexlit2 403 0x10000000000000000  1.844674e+19

finish_test







|
|
|
|


138
139
140
141
142
143
144
145
146
147
148
149
150
hexlit2 324 0x1000000000000000000000000 7.922816e+28
hexlit2 325 0x10000000000000000000000000 1.267651e+30
hexlit2 326 0x100000000000000000000000000 2.028241e+31
hexlit2 327 0x1000000000000000000000000000 3.245186e+32
hexlit2 328 0x10000000000000000000000000000 5.192297e+33
hexlit2 329 0x100000000000000000000000000000 8.307675e+34

hexlit2 400 0x07fffffffffffffff 9.223372e+18
hexlit2 401 0x08000000000000000 9.223372e+18
hexlit2 402 0x0ffffffffffffffff 1.844674e+19
hexlit2 403 0x10000000000000000 1.844674e+19

finish_test