Latch... In DBC the max value can not be over 1,000,000. IF the number is over 1,000,000 then it uses 1.00000000E100 . I want the hole number.
New version of the program. An lot faster. Now the maths is handle with two for next loop. Also with the zip file is some txt files.
Here is the code for the program i hope you like it.
SET EMULATION on : sync rate 0 : sync on : HIDE mouse
List_Count = 0
wait_Timer = 2000
start:
cls 0
UpDate_Timer = Timer()
Print " "
print "By Joseph Allen ( ALIEN ) "
print "Cal 2 to the power of N"
Print "Check txt files to see the Number"
Print " "
input "Enter Value of N: "; target_Number
IF target_Number = 0 then goto end_Program
Mem_size = ( target_Number / 3 ) + 1
Dim Large_Number( Mem_size )
FileName$ = "2 to the power of " + str$( target_Number ) + ".txt"
IF FILE EXIST( FileName$ ) = 1
IF FILE SIZE( FileName$ ) = 0
DELETE FILE FileName$
else
cls 0
print " "
print "Allready cal that power."
wait wait_Timer
UNDIM Large_Number( Mem_size , 1 )
goto start
endif
endif
open to write 1 , FileName$
Line_Count = 1
Large_Number(1,0) = 2
Per_Sec = 0
ink RGB(255,255,255) , 0
gosub Up_date_screen
FOR N = 1 to target_Number
IF N = target_Number then Write_to_File( Line_Count , Mem_size )
Nx2( int(N / 3) + 1 )
Line_Count = Line_Count + 1
IF TIMER() >= UpDate_Timer + 1000
UpDate_Timer = TIMER()
gosub Up_date_screen
Per_Sec = 0
endif
Per_Sec = Per_Sec + 1
NEXT N
close file 1
gosub Up_date_screen
wait wait_Timer
UNDIM Large_Number( Mem_size )
goto start:
end_Program:
cls 0
sync
end
rem =========================================================================
Up_date_screen:
cls 0
text 100 , 100 , "Current 2 power of " + str$( Line_Count - 1)
text 100 , 140 , "Left to do: " + str$( (target_Number + 1) - Line_Count )
text 100 , 180 , "Per second: " + str$( Per_Sec )
sync
return
Function Write_to_File( L_C , T_N )
TEMP_STRING$ = ""
Start_OF_Number = 0
Large_Number = 0
FOR N = T_N to 1 step -1
IF Start_OF_Number = 0
IF Large_Number(N) > 0 then Start_OF_Number = 1
endif
IF Start_OF_Number = 1
TEMP_STRING$ = TEMP_STRING$ + str$( Large_Number(N) )
IF len( TEMP_STRING$ ) >= 100
IF Large_Number = 1 then write string 1 , TEMP_STRING$
IF Large_Number = 0
write string 1 , "2 to the power of " +str$( L_C )
write string 1 , TEMP_STRING$
Large_Number = 1
endif
TEMP_STRING$ = ""
endif
endif
NEXT N
IF Large_Number = 0
write string 1 , "2 to the power of " +str$( L_C )
write string 1 , TEMP_STRING$
endif
IF Large_Number = 1 and LEN( TEMP_STRING$ ) > 0 then write string 1 , TEMP_STRING$
write string 1 , ""
endfunction
Function Nx2( t_N )
Number_Add = 0
FOR N = 1 to t_N
Large_Number(N) = Large_Number(N) + Large_Number(N)
IF Number_Add = 1 then Large_Number(N) = Large_Number(N) + 1 : Number_Add = 0
IF Large_Number(N) > 9 then Large_Number(N) = Large_Number(N) - 10 : Number_Add = 1
Next N
endfunction