Re: Phix, numbers, printf, log10

new topic     » goto parent     » topic index » view thread      » older message » newer message
RobertS said...

printf(1, "%e", 12)
1.220000e+1

OK, I've aligned the "fwk" side with the "(f-digit)*10" side and got rid of fadj, and pushed all this to https://raw.githubusercontent.com/petelomax/Phix/master/builtins/VM/pprntfN.e which you may find much easier:

@ -218,20 +218,26 @@ end for 
                fwk += epwr 
                digit += 1 
            end while 
--24/2/24: 
            f -= fwk 
        else 
            digit = floor(f) 
--21/2/24: 
            f = (f-digit)*10 
        end if 
        result &= digit+'0' 
        expadj = 1 
        if precision>0 then 
            result &= '.' 
            dotdone = 1 
--24/2/24: 
--          atom fadj = 0 
--1/11/15 
--          for i=1 to precision do 
            for i=1 to precision-(charflag='g') do 
                if ewk>0 then 
--24/2/24: 
--                  f -= fwk 
                    ewk -= 1 
                    epwr = power(10,ewk) 
                    fwk = 0--epwr 
@ -240,19 +246,25 @@ end for 
                        fwk += epwr 
                        digit += 1 
                    end while 
--24/2/24: 
--30/10/21 
--                  fadj = fwk 
                    f -= fwk 
                else 
--21/2/24 
--                  f = (f-digit)*10 
                    digit = floor(f) 
                    f = (f-digit)*10 
--24/2/24: 
--                  fadj = 0 
                end if 
--12/7/16: 
                if digit=10 then exit end if 
                result &= digit+'0' 
                expadj += 1 
            end for 
--24/2/24: 
--          f -= fadj 
        else 
            if ewk>0 then 
                f -= fwk 

Clearly "p -test" is missing a whole bunch of "%e"-related stuff.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu