Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Text conversion to big number
Message
De
28/09/2020 07:00:57
 
 
À
26/09/2020 12:09:31
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01676260
Message ID:
01676290
Vues:
54
There used to be a bignum library from a South American not around here for some years - cannot remember his name at the moment, only that he believed in Ba'hai... weird lapses between my ears ;-)

That said - if there is ANY chance you need to do more with such big numbers, I'd link in a class coded in Python via COM. Python plus Vfp via COM is not that hard (get the very old O'Reilly book with the alligator on front) and Python has 'long literal' datatype supporting any kind of whole number math with it (already tested for scientific use) plus a 'decimal' module, featuring a 'Decimal' type that provides real numbers of arbitrary size and precision (also tested), missing the typical issues inherent to binary floating-point representations.

Of course such a step adds Python to install routines - but that should not create problem unless you target thousands of users where a few are bound to have crazy machine installs already.

YMMV - this is coming from a "numbers" guy doing contortions to always have those correct...

thomas

P.S.
If you avoid long source single lines, text here is readable without 4k screen, see added >> break

>I need to convert a text. e.g 1.2.11.3 to a number like 1021103 for which I constructed a method:
>
>
>*!* PROCEDURE conversion
>LPARAMETERS lcNumberIn
>
>Local ;
>	lcNewpar As String, ;
>	lcNumberIn As String, ;
>	lnI As Number, ;
>	lnParenteel As Number
>
>
>*!*	? lcNumberIn
>m.lcNewpar = ''
>
>For m.lnI = 1 To Len(Alltrim(m.lcNumberIn ))
>	Do Case
>		Case !Isdigit(Substr(m.lcNumberIn ,m.lnI,1))
>			m.lcNewpar = m.lcNewpar +Substr(m.lcNumberIn ,m.lnI,1)
>		Case Isdigit(Substr(m.lcNumberIn ,m.lnI,1))
>			m.lcNewpar = m.lcNewpar + Iif(Isdigit(Substr(m.lcNumberIn ,m.lnI,1))
>>                        , Padl(Substr(m.lcNumberIn ,m.lnI,1),2,'0'),Substr(lcParenteel  ,m.lnI,1))
>
>	Endcase
>Endfor 
>m.lcNewpar = Strtran(m.lcNewpar ,'010','1')
>m.lcNewpar = Strtran(m.lcNewpar ,'.','')
>m.lcNewpar = ALLTRIM(Substr(m.lcNewpar ,2))
>RETURN val(m.lcNewpar)
>
>
>Now I come to a text 1.4.2.1.9.1.4.4.1.1.1 which would be 104020109010404010101 however this are to much digits vor VFP to handle thus my method gives 1040201090104+E
>
>How to solve for such big numbers?
>Stay healty,
>Koen
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform