Информационный сервер для программистов: Исходники со всего света. Паскальные исходники со всего света
  Powered by Поисковый сервер Яndex: Найдется ВСЁ!
На Главную Pascal Форум Информер Страны мира
   Математика    >>    vln
   
 
 Very Large Numbers - up to 1000 Decimal Digits  Unknown 04.11.1993

Very Large Numbers - allows the Pascal programmer to work with numbers up to 1000 decimal digits or more. VLN can also handle numbers to 1* 10 ^ -1000 or smaller as well as add, subtract, multiply, divide, and perform with roots and powers.



67k 
 

Very Large Numbers - VLN This Object Class allows the user to compute to very high precision. The unique feature of this Object class is that numbers are supported up to 1000 decimal digits or more, limited only by available memory. While only integer data is supported, scaled arithmetic allows numbers to be used as small as 1 x 10 ^ -1000 or smaller. Several basic operations are provided such as add, subtract, multiply and divide. Further useful operations include 2^n, 10^n, nth-power and nth-Root. Write Hexadecimal and Write Decimal procedures are included. Object definition: )))))))))))))))))))))))))))))))))))))))))) )) )) )) pWordArray = ^tWordArray )) )) tWordArray = object )) )) array[1..vlsize] of word; )) )) end; )) )) )) )) pVryLrgNo =^tVryLrgNo; )) )) tVryLrgNo = object )) )) count : integer; )) )) max : integer; )) )) sign : integer; )) )) tVLN : tWordArray; )) )) )) )) procedures and functions. )) )) end; )) )) )) )))))))))))))))))))))))))))))))))))))))))) One problem in defining this data type, that can contain more than a thousand bytes, is that there is no best size for 'vlsize' the maximum allowed size. Some applications will need a few numbers of immense size while others will need many but not so big. The user, if he does nothing special may use the default size of 1000 words (which allows 5300 decimal digits) for all variables in his program. A way is illustrated to use less memory assuming he knows how large the numbers will actually be. This method uses GETMEM( name, size) In the process of initializing a VLN variable, the programmer also specifies 'MAX' the maximum size expected and this is tested in all arithmetic procedures. The main program is responsible for OpenTempRegs at the start and CloseTempRegs at the end as well as disposing of any dynamic variables that are created. This is to allow the user to specify maximum size of the VLN