Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Numeric overflow issue
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00588052
Message ID:
00589741
Views:
44
Chris --

Interesting thread. One more nuance that I've explored as a result.

Overflow values can have a signed value.

In memory -- they always do, including -1/0
In tables, they can, depending on a couple factors. The numeric field has to be large enough to contain a sign -- otherwise it's positive. -1/0 never is signed. But, other overflow conditions are signed in fields if the field can contain a sign.

So, in your algorithm, you'd want use ABS() to return the absolute value from the table's field.

Jay

>TRANSFORM is substancially slower.
>
>
>USE myTable
>
>* Test 1 Million TRANSFORMS
>t= SECONDS()
>FOR i = 1 TO 1000000
>	x= '*' $ TRANSFORM(Num)
>ENDFOR
>?SECONDS() - t
>* 5.057 seconds
>
>* Test 1 Million Comparisons
>t= SECONDS()
>FOR i = 1 TO 1000000
>	x= Num > 99999999    && Field Length is 8
>ENDFOR
>?SECONDS() - t
>* 1.322 Seconds
>
>CLOSE DATA
>
>
>almost 4 seconds slower over a million tests.
>put this over a substancial data set and you would be getting quite the performance hit.
>
>
>>>>Chris and Antonio,
>>>>
>>>>Testing for myField = 1/0 returns true on a field with a numeric overflow condition. So this should be a good general solution, or you could SCAN/ENDSCAN and check the condition on each record if necessary:
>>>>
>>>>REPLACE myField with 0 for myField = 1/0
>>>>
>>>>>
>>>>>AFIELDS gives some info, and there are a few more that I cant think of off the top of my head.
>>>>>But by passing the Size and Dec you can use this for more then just a field of an opened database. Making it a general approach.
>>>>>If I was doing something with checking for overflows, I would no doubt do an AFIELDS()
>>>>>then Loop through that, take the size and precision, pass it into the above code, and then replace for myField > maxVal, though it isnt the best way to do the replacement either, replace for locks the entire table if im not mistaken.
>>>>>
>>>
>>>I can not get that condition to be true.
>>>I overflowed a field,
>>>
>>>
>>>?FSize("Num")   => 5
>>>REPLACE Num WITH 99999999999
>>>? Num            => *******
>>>? Num = 1/0      => .F.
>>>
>>
>>Try:
>>
>>
>>? "*" $ TRANSFORM (Num)
>>
>>
>> Jay
Previous
Reply
Map
View

Click here to load this message in the networking platform