diff --git a/classlib/src/main/java/org/teavm/classlib/impl/text/DoubleAnalyzer.java b/classlib/src/main/java/org/teavm/classlib/impl/text/DoubleAnalyzer.java index 075a2226f..b13bed31b 100644 --- a/classlib/src/main/java/org/teavm/classlib/impl/text/DoubleAnalyzer.java +++ b/classlib/src/main/java/org/teavm/classlib/impl/text/DoubleAnalyzer.java @@ -94,7 +94,7 @@ public final class DoubleAnalyzer { result.exponent = decExponent - MAX_ABS_DEC_EXP; } - private static long findLowerDistance(long mantissa, long lower) { + static long findLowerDistance(long mantissa, long lower) { long pos = 1; while (Long.compareUnsigned( Long.divideUnsigned(mantissa, pos * 10), @@ -104,7 +104,7 @@ public final class DoubleAnalyzer { return pos; } - private static long findUpperDistance(long mantissa, long upper) { + static long findUpperDistance(long mantissa, long upper) { long pos = 1; while (Long.compareUnsigned( Long.divideUnsigned(mantissa, pos * 10), @@ -147,7 +147,7 @@ public final class DoubleAnalyzer { // Numbers in the table below are generated by DoubleAnalyzerGenerator - private static long[] mantissa10Table = { + static long[] mantissa10Table = { -9023189732560287392L, -3369057127870728857L, -6384594517038493409L, diff --git a/classlib/src/main/java/org/teavm/classlib/impl/text/DoubleSynthesizer.java b/classlib/src/main/java/org/teavm/classlib/impl/text/DoubleSynthesizer.java index d20cd61c9..5a2cc7b92 100644 --- a/classlib/src/main/java/org/teavm/classlib/impl/text/DoubleSynthesizer.java +++ b/classlib/src/main/java/org/teavm/classlib/impl/text/DoubleSynthesizer.java @@ -20,21 +20,22 @@ public final class DoubleSynthesizer { } public static double synthesizeDouble(long mantissa, int exp, boolean negative) { - var indexInTable = DoubleAnalyzer.MAX_ABS_DEC_EXP - exp; - if (mantissa == 0 || indexInTable > DoubleSynthesizer.mantissa10Table.length || indexInTable < 0) { + var indexInTable = DoubleAnalyzer.MAX_ABS_DEC_EXP + exp; + if (mantissa == 0 || indexInTable > mantissa10Table.length || indexInTable < 0) { return Double.longBitsToDouble(negative ? (1L << 63) : 0); } - var binMantissa = DoubleAnalyzer.mulAndShiftRight(mantissa, DoubleSynthesizer.mantissa10Table[indexInTable], 0); - var binExp = DoubleSynthesizer.exp10Table[indexInTable] - 1; - while ((binMantissa & (-1L << 58L)) != 0) { - binMantissa >>>= 1; - binExp++; - } - while (binMantissa < (1L << 57)) { - binMantissa <<= 1; - binExp--; + var binMantissa = DoubleAnalyzer.mulAndShiftRight(mantissa, mantissa10Table[indexInTable], 0); + var binExp = exp10Table[indexInTable]; + + var binMantissaShift = (64 - Long.numberOfLeadingZeros(binMantissa)) - 58; + if (binMantissaShift >= 0) { + binMantissa >>>= binMantissaShift; + } else { + binMantissa <<= -binMantissaShift; } + binExp += binMantissaShift; + if (binExp >= 2047) { return negative ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY; } @@ -59,1328 +60,1328 @@ public final class DoubleSynthesizer { // Numbers in the table below are generated by DoubleSynthesizerGenerator private static final long[] mantissa10Table = { - -5920691823653471754L, - -8425902273664687727L, - -2413397193637769393L, - -5620066569652125837L, - -8185402070463610993L, - -2028596868516046619L, - -5312226309554747619L, - -7939129862385708418L, - -1634561335591402499L, - -4996997883215032323L, - -7686947121313936181L, - -1231068949876566920L, - -4674203974643163860L, - -7428711994456441411L, - -817892746904575288L, - -4343663012265570553L, - -7164279224554366766L, - -394800315061255856L, - -4005189066790915008L, - -6893500068174642330L, - -9204148869281624187L, - -3658591746624867729L, - -6616222212041804507L, - -8982326584375353929L, - -3303676090774835316L, - -6332289687361778576L, - -8755180564631333184L, - -2940242459184402125L, - -6041542782089432023L, - -8522583040413455942L, - -2568086420435798537L, - -5743817951090549153L, - -8284403175614349646L, - -2186998636757228463L, - -5438947724147693094L, - -8040506994060064798L, - -1796764746270372707L, - -5126760611758208489L, - -7790757304148477115L, - -1397165242411832414L, - -4807081008671376254L, - -7535013621679011327L, - -987975350460687153L, - -4479729095110460046L, - -7273132090830278360L, - -568964901102714406L, - -4144520735624081848L, - -7004965403241175802L, - -139898200960150313L, - -3801267375510030573L, - -6730362715149934782L, - -9073638986861858149L, - -3449775934753242068L, - -6449169562544503978L, - -8848684464777513506L, - -3089848699418290639L, - -6161227774276542835L, - -8618331034163144591L, - -2721283210435300376L, - -5866375383090150624L, - -8382449121214030822L, - -2343872149716718346L, - -5564446534515285000L, - -8140906042354138323L, - -1957403223540890347L, - -5255271393574622601L, - -7893565929601608404L, - -1561659043136842477L, - -4938676049251384305L, - -7640289654143017767L, - -1156417002403097458L, - -4614482416664388289L, - -7380934748073420955L, - -741449152691742558L, - -4282508136895304370L, - -7115355324258153819L, - -316522074587315140L, - -3942566474411762436L, - -6843401994271320272L, - -9164070410158966541L, - -3594466212028615495L, - -6564921784364802720L, - -8941286242233752499L, - -3238011543348273028L, - -6279758049420528746L, - -8713155254278333320L, - -2873001962619602342L, - -5987750384837592197L, - -8479549122611984081L, - -2499232151953443560L, - -5688734536304665171L, - -8240336443785642460L, - -2116491865831296966L, - -5382542307406947896L, - -7995382660667468640L, - -1724565812842218855L, - -5069001465015685407L, - -7744549986754458649L, - -1323233534581402868L, - -4747935642407032618L, - -7487697328667536418L, - -912269281642327298L, - -4419164240055772162L, - -7224680206786528053L, - -491441886632713915L, - -4082502324048081455L, - -6955350673980375487L, - -60514634142869810L, - -3737760522056206171L, - -6679557232386875260L, - -9032994600651410532L, - -3384744916816525881L, - -6397144748195131028L, - -8807064613298015146L, - -3023256937051093263L, - -6107954364382784934L, - -8575712306248138270L, - -2653093245771290262L, - -5811823411358942533L, - -8338807543829064350L, - -2274045625900771990L, - -5508585315462527915L, - -8096217067111932656L, - -1885900863153361279L, - -5198069505264599346L, - -7847804418953589800L, - -1488440626100012711L, - -4880101315621920492L, - -7593429867239446717L, - -1081441343357383777L, - -4554501889427817345L, - -7332950326284164199L, - -664674077828931749L, - -4221088077005055722L, - -7066219276345954901L, - -237904397927796872L, - -3879672333084147821L, - -6793086681209228580L, - -9123818159709293187L, - -3530062611309138130L, - -6513398903789220827L, - -8900067937773286985L, - -3172062256211528206L, - -6226998619711132888L, - -8670947710510816634L, - -2805469892591575644L, - -5933724728815170839L, - -8436328597794046994L, - -2430079312244744221L, - -5633412264537705700L, - -8196078626372074883L, - -2045679357969588844L, - -5325892301117581398L, - -7950062655635975442L, - -1652053804791829737L, - -5010991858575374113L, - -7698142301602209614L, - -1248981238337804412L, - -4688533805412153853L, - -7440175859071633406L, - -836234930288882479L, - -4358336758973016307L, - -7176018221920323369L, - -413582710846786420L, - -4020214983419339459L, - -6905520801477381891L, - -9213765455923815836L, - -3673978285252374367L, - -6628531442943809817L, - -8992173969096958177L, - -3319431906329402113L, - -6344894339805432014L, - -8765264286586255934L, - -2956376414312278525L, - -6054449946191733143L, - -8532908771695296838L, - -2584607590486743971L, - -5757034887131305500L, - -8294976724446954723L, - -2203916314889396588L, - -5452481866653427593L, - -8051334308064652398L, - -1814088448677712867L, - -5140619573684080617L, - -7801844473689174817L, - -1414904713676948737L, - -4821272585683469313L, - -7546366883288685774L, - -1006140569036166268L, - -4494261269970843337L, - -7284757830718584993L, - -587566084924005019L, - -4159401682681114339L, - -7016870160886801794L, - -158945813193151901L, - -3816505465296431844L, - -6742553186979055799L, - -9083391364325154962L, - -3465379738694516970L, - -6461652605697523899L, - -8858670899299929442L, - -3105826994654156138L, - -6174010410465235234L, - -8628557143114098510L, - -2737644984756826647L, - -5879464802547371641L, - -8392920656779807636L, - -2360626606621961247L, - -5577850100039479321L, - -8151628894773493780L, - -1974559787411859078L, - -5268996644671397586L, - -7904546130479028392L, - -1579227364540714458L, - -4952730706374481889L, - -7651533379841495835L, - -1174406963520662366L, - -4628874385558440216L, - -7392448323188662496L, - -759870872876129024L, - -4297245513042813542L, - -7127145225176161157L, - -335385916056126881L, - -3957657547586811828L, - -6855474852811359786L, - -9173728696990998152L, - -3609919470959866074L, - -6577284391509803182L, - -8951176327949752869L, - -3253835680493873621L, - -6292417359137009220L, - -8723282702051517699L, - -2889205879056697349L, - -6000713517987268202L, - -8489919629131724885L, - -2515824962385028846L, - -5702008784649933400L, - -8250955842461857044L, - -2133482903713240300L, - -5396135137712502563L, - -8006256924911912374L, - -1741964635633328828L, - -5082920523248573386L, - -7755685233340769032L, - -1341049929119499481L, - -4762188758037509908L, - -7499099821171918250L, - -930513269649338230L, - -4433759430461380907L, - -7236356359111015049L, - -510123730351893109L, - -4097447799023424810L, - -6967307053960650171L, - -79644842111309304L, - -3753064688430957767L, - -6691800565486676537L, - -9042789267131251553L, - -3400416383184271515L, - -6409681921289327535L, - -8817094351773372351L, - -3039304518611664792L, - -6120792429631242157L, - -8585982758446904049L, - -2669525969289315508L, - -5824969590173362730L, - -8349324486880600507L, - -2290872734783229842L, - -5522047002568494197L, - -8106986416796705681L, - -1903131822648998119L, - -5211854272861108819L, - -7858832233030797378L, - -1506085128623544835L, - -4894216917640746191L, - -7604722348854507276L, - -1099509313941480672L, - -4568956265895094861L, - -7344513827457986212L, - -683175679707046970L, - -4235889358507547899L, - -7078060301547948643L, - -256850038250986858L, - -3894828845342699810L, - -6805211891016070171L, - -9133518327554766460L, - -3545582879861895366L, - -6525815118631426616L, - -8910000909647051616L, - -3187955011209551616L, - -6239712823709551616L, - -8681119073709551616L, - -2821744073709551616L, - -5946744073709551616L, - -8446744073709551616L, - -2446744073709551616L, - -5646744073709551616L, - -8206744073709551616L, - -2062744073709551616L, - -5339544073709551616L, - -7960984073709551616L, - -1669528073709551616L, - -5024971273709551616L, - -7709325833709551616L, - -1266874889709551616L, - -4702848726509551616L, - -7451627795949551616L, - -854558029293551616L, - -4372995238176751616L, - -7187745005283311616L, - -432345564227567616L, - -4035225266123964416L, - -6917529027641081856L, - -9223372036854775808L, - -3689348814741910324L, - -6640827866535438582L, - -9002011107970261189L, - -3335171328526686933L, - -6357485877563259869L, - -8775337516792518219L, - -2972493582642298180L, - -6067343680855748868L, - -8543223759426509417L, - -2601111570856684098L, - -5770238071427257602L, - -8305539271883716405L, - -2220816390788215277L, - -5466001927372482545L, - -8062150356639896359L, - -1831394126398103205L, - -5154464115860392887L, - -7812920107430224633L, - -1432625727662628443L, - -4835449396872013078L, - -7557708332239520786L, - -1024286887357502287L, - -4508778324627912153L, - -7296371474444240046L, - -606147914885053103L, - -4174267146649952806L, - -7028762532061872568L, - -177973607073265139L, - -3831727700400522434L, - -6754730975062328271L, - -9093133594791772940L, - -3480967307441105734L, - -6474122660694794911L, - -8868646943297746252L, - -3121788665050663033L, - -6186779746782440750L, - -8638772612167862923L, - -2753989735242849707L, - -5892540602936190089L, - -8403381297090862394L, - -2377363631119648861L, - -5591239719637629412L, - -8162340590452013853L, - -1991698500497491195L, - -5282707615139903279L, - -7915514906853832947L, - -1596777406740401745L, - -4966770740134231719L, - -7662765406849295699L, - -1192378206733142148L, - -4643251380128424042L, - -7403949918844649557L, - -778273425925708321L, - -4311967555482476980L, - -7138922859127891907L, - -354230130378896082L, - -3972732919045027189L, - -6867535149977932074L, - -9183376934724255983L, - -3625356651333078602L, - -6589634135808373205L, - -8961056123388608887L, - -3269643353196043250L, - -6305063497298744923L, - -8733399612580906262L, - -2905392935903719049L, - -6013663163464885563L, - -8500279345513818773L, - -2532400508596379068L, - -5715269221619013577L, - -8261564192037121185L, - -2150456263033662926L, - -5409713825168840664L, - -8017119874876982855L, - -1759345355577441598L, - -5096825099203863602L, - -7766808894105001205L, - -1358847786342270957L, - -4776427043815727089L, - -7510490449794491995L, - -948738275445456222L, - -4448339435098275301L, - -7248020362820530564L, - -528786136287117932L, - -4112377723771604669L, - -6979250993759194058L, - -98755145788979524L, - -3768352931373093942L, - -6704031159840385477L, - -9052573742614218705L, - -3416071543957018958L, - -6422206049907525490L, - -8827113654667930715L, - -3055335403242958174L, - -6133617137336276863L, - -8596242524610931813L, - -2685941595151759932L, - -5838102090863318269L, - -8359830487432564938L, - -2307682335666372931L, - -5535494683275008668L, - -8117744561361917258L, - -1920344853953336643L, - -5225624697904579637L, - -7869848573065574033L, - -1523711272679187483L, - -4908317832885260310L, - -7616003081050118571L, - -1117558485454458744L, - -4583395603105477319L, - -7356065297226292178L, - -701658031336336515L, - -4250675239810979535L, - -7089889006590693952L, - -275775966319379353L, - -3909969587797413806L, - -6817324484979841368L, - -9143208402725783417L, - -3561087000135522498L, - -6538218414850328322L, - -8919923546622172981L, - -3203831230369745799L, - -6252413799037706963L, - -8691279853972075893L, - -2838001322129590460L, - -5959749872445582691L, - -8457148712698376476L, - -2463391496091671392L, - -5660062011615247437L, - -8217398424034108273L, - -2079791034228842266L, - -5353181642124984136L, - -7971894128441897632L, - -1686984161281305242L, - -5038936143766954517L, - -7720497729755473937L, - -1284749923383027329L, - -4717148753448332187L, - -7463067817500576073L, - -872862063775190746L, - -4387638465762062920L, - -7199459587351560659L, - -451088895536766085L, - -4050219931171323192L, - -6929524759678968877L, - -19193171260619233L, - -3704703351750405709L, - -6653111496142234891L, - -9011838011655698236L, - -3350894374423386208L, - -6370064314280619289L, - -8785400266166405755L, - -2988593981640518238L, - -6080224000054324913L, - -8553528014785370254L, - -2617598379430861437L, - -5783427518286599473L, - -8316090829371189901L, - -2237698882768172872L, - -5479507920956448621L, - -8072955151507069220L, - -1848681798185579782L, - -5168294253290374149L, - -7823984217374209643L, - -1450328303573004458L, - -4849611457600313890L, - -7569037980822161435L, - -1042414325089727327L, - -4523280274813692185L, - -7307973034592864071L, - -624710411122851544L, - -4189117143640191558L, - -7040642529654063570L, - -196981603220770742L, - -3846934097318526917L, - -6766896092596731857L, - -9102865688819295809L, - -3496538657885142324L, - -6486579741050024183L, - -8878612607581929669L, - -3137733727905356501L, - -6199535797066195524L, - -8648977452394866743L, - -2770317479606055818L, - -5905602798426754978L, - -8413831053483314306L, - -2394083241347571919L, - -5604615407819967859L, - -8173041140997884610L, - -2008819381370884406L, - -5296404319838617848L, - -7926472270612804602L, - -1614309188754756393L, - -4980796165745715438L, - -7673985747338482674L, - -1210330751515841308L, - -4657613415954583370L, - -7415439547505577019L, - -796656831783192261L, - -4326674280168464132L, - -7150688238876681629L, - -373054737976959636L, - -3987792605123478032L, - -6879582898840692749L, - -9193015133814464522L, - -3640777769877412266L, - -6601971030643840136L, - -8970925639256982432L, - -3285434578585440922L, - -6317696477610263061L, - -8743505996830120772L, - -2921563150702462265L, - -6026599335303880135L, - -8510628282985014432L, - -2548958808550292121L, - -5728515861582144020L, - -8272161504007625539L, - -2167411962186469893L, - -5423278384491086237L, - -8027971522334779313L, - -1776707991509915931L, - -5110715207949843068L, - -7777920981101784778L, - -1376627125537124675L, - -4790650515171610063L, - -7521869226879198374L, - -966944318780986428L, - -4462904269766699466L, - -7259672230555269896L, - -547429124662700864L, - -4127292114472071014L, - -6991182506319567135L, - -117845565885576446L, - -3783625267450371480L, - -6716249028702207507L, - -9062348037703676329L, - -3431710416100151157L, - -6434717147622031249L, - -8837122532839535322L, - -3071349608317525546L, - -6146428501395930760L, - -8606491615858654931L, - -2702340141148116920L, - -5851220927660403859L, - -8370325556870233411L, - -2324474446766642487L, - -5548928372155224313L, - -8128491512466089774L, - -1937539975720012668L, - -5239380795317920458L, - -7880853450996246689L, - -1541319077368263733L, - -4922404076636521310L, - -7627272076051127371L, - -1135588877456072824L, - -4597819916706768583L, - -7367604748107325189L, - -720121152745989333L, - -4265445736938701790L, - -7101705404292871755L, - -294682202642863838L, - -3925094576856201394L, - -6829424476226871438L, - -9152888395723407474L, - -3576574988931720989L, - -6550608805887287114L, - -8929835859451740015L, - -3219690930897053053L, - -6265101559459552766L, - -8701430062309552536L, - -2854241655469553088L, - -5972742139117552794L, - -8467542526035952558L, - -2480021597431793123L, - -5673366092687344822L, - -8228041688891786181L, - -2096820258001126919L, - -5366805021142811859L, - -7982792831656159810L, - -1704422086424124727L, - -5052886483881210105L, - -7731658001846878407L, - -1302606358729274481L, - -4731433901725329908L, - -7474495936122174250L, - -891147053569747830L, - -4402266457597708587L, - -7211161980820077193L, - -469812725086392539L, - -4065198994811024355L, - -6941508010590729807L, - -38366372719436721L, - -3720041912917459700L, - -6665382345075878084L, - -9021654690802612790L, - -3366601061058449494L, - -6382629663588669919L, - -8795452545612846258L, - -3004677628754823043L, - -6093090917745768758L, - -8563821548938525330L, - -2634068034075909558L, - -5796603242002637969L, - -8326631408344020699L, - -2254563809124702148L, - -5492999862041672042L, - -8083748704375247957L, - -1865951482774665761L, - -5182110000961642932L, - -7835036815511224669L, - -1468012460592228501L, - -4863758783215693124L, - -7580355841314464822L, - -1060522901877412746L, - -4537767136243840520L, - -7319562523736982739L, - -643253593753441413L, - -4203951689744663454L, - -7052510166537641086L, - -215969822234494768L, - -3862124672529506138L, - -6779048552765515233L, - -9112587656954322510L, - -3512093806901185046L, - -6499023860262858360L, - -8888567902952197011L, - -3153662200497784248L, - -6212278575140137722L, - -8659171674854020501L, - -2786628235540701832L, - -5918651403174471789L, - -8424269937281487754L, - -2410785455424649437L, - -5617977179081629873L, - -8183730558007214222L, - -2025922448585811785L, - -5310086773610559751L, - -7937418233630358124L, - -1631822729582842029L, - -4994806998408183946L, - -7685194413468457480L, - -1228264617323800998L, - -4671960508600951122L, - -7426917221622671221L, - -815021110370542984L, - -4341365703038344710L, + -391859759250406776L, -7162441377172586091L, + -4341365703038344710L, + -815021110370542983L, + -7426917221622671220L, + -4671960508600951122L, + -1228264617323800998L, + -7685194413468457480L, + -4994806998408183946L, + -1631822729582842028L, + -7937418233630358124L, + -5310086773610559750L, + -2025922448585811784L, + -8183730558007214221L, + -5617977179081629872L, + -2410785455424649436L, + -8424269937281487754L, + -5918651403174471788L, + -2786628235540701831L, + -8659171674854020500L, + -6212278575140137722L, + -3153662200497784248L, + -8888567902952197011L, + -6499023860262858360L, + -3512093806901185046L, + -9112587656954322510L, + -6779048552765515233L, + -3862124672529506137L, + -215969822234494767L, + -7052510166537641086L, + -4203951689744663453L, + -643253593753441412L, + -7319562523736982739L, + -4537767136243840519L, + -1060522901877412745L, + -7580355841314464822L, + -4863758783215693123L, + -1468012460592228500L, + -7835036815511224669L, + -5182110000961642932L, + -1865951482774665761L, + -8083748704375247956L, + -5492999862041672041L, + -2254563809124702148L, + -8326631408344020698L, + -5796603242002637969L, + -2634068034075909557L, + -8563821548938525329L, + -6093090917745768758L, + -3004677628754823043L, + -8795452545612846258L, + -6382629663588669918L, + -3366601061058449494L, + -9021654690802612790L, + -6665382345075878083L, + -3720041912917459700L, + -38366372719436721L, + -6941508010590729807L, + -4065198994811024354L, + -469812725086392539L, + -7211161980820077193L, + -4402266457597708587L, + -891147053569747830L, + -7474495936122174249L, + -4731433901725329908L, + -1302606358729274481L, + -7731658001846878407L, + -5052886483881210104L, + -1704422086424124726L, + -7982792831656159810L, + -5366805021142811858L, + -2096820258001126919L, + -8228041688891786180L, + -5673366092687344821L, + -2480021597431793123L, + -8467542526035952558L, + -5972742139117552793L, + -2854241655469553087L, + -8701430062309552536L, + -6265101559459552766L, + -3219690930897053053L, + -8929835859451740014L, + -6550608805887287114L, + -3576574988931720988L, + -9152888395723407474L, + -6829424476226871438L, + -3925094576856201393L, + -294682202642863838L, + -7101705404292871755L, + -4265445736938701789L, + -720121152745989333L, + -7367604748107325189L, + -4597819916706768582L, + -1135588877456072824L, + -7627272076051127371L, + -4922404076636521309L, + -1541319077368263733L, + -7880853450996246689L, + -5239380795317920457L, + -1937539975720012667L, + -8128491512466089773L, + -5548928372155224312L, + -2324474446766642487L, + -8370325556870233410L, + -5851220927660403859L, + -2702340141148116919L, + -8606491615858654931L, + -6146428501395930759L, + -3071349608317525545L, + -8837122532839535322L, + -6434717147622031248L, + -3431710416100151156L, + -9062348037703676329L, + -6716249028702207507L, + -3783625267450371479L, + -117845565885576445L, + -6991182506319567134L, + -4127292114472071014L, + -547429124662700863L, + -7259672230555269896L, + -4462904269766699465L, + -966944318780986428L, + -7521869226879198373L, + -4790650515171610063L, + -1376627125537124674L, + -7777920981101784777L, + -5110715207949843068L, + -1776707991509915931L, + -8027971522334779313L, + -5423278384491086237L, + -2167411962186469892L, + -8272161504007625539L, + -5728515861582144019L, + -2548958808550292120L, + -8510628282985014431L, + -6026599335303880135L, + -2921563150702462265L, + -8743505996830120771L, + -6317696477610263060L, + -3285434578585440921L, + -8970925639256982432L, + -6601971030643840136L, + -3640777769877412266L, + -9193015133814464522L, + -6879582898840692748L, + -3987792605123478032L, + -373054737976959636L, + -7150688238876681628L, + -4326674280168464131L, + -796656831783192260L, + -7415439547505577019L, + -4657613415954583369L, + -1210330751515841307L, + -7673985747338482673L, + -4980796165745715437L, + -1614309188754756393L, + -7926472270612804602L, + -5296404319838617848L, + -2008819381370884406L, + -8173041140997884610L, + -5604615407819967858L, + -2394083241347571919L, + -8413831053483314305L, + -5905602798426754977L, + -2770317479606055818L, + -8648977452394866742L, + -6199535797066195524L, + -3137733727905356501L, + -8878612607581929669L, + -6486579741050024182L, + -3496538657885142324L, + -9102865688819295808L, + -6766896092596731856L, + -3846934097318526916L, + -196981603220770741L, + -7040642529654063569L, + -4189117143640191558L, + -624710411122851543L, + -7307973034592864070L, + -4523280274813692184L, + -1042414325089727326L, + -7569037980822161435L, + -4849611457600313890L, + -1450328303573004458L, + -7823984217374209642L, + -5168294253290374149L, + -1848681798185579782L, + -8072955151507069220L, + -5479507920956448621L, + -2237698882768172872L, + -8316090829371189901L, + -5783427518286599472L, + -2617598379430861436L, + -8553528014785370254L, + -6080224000054324913L, + -2988593981640518237L, + -8785400266166405754L, + -6370064314280619289L, + -3350894374423386207L, + -9011838011655698235L, + -6653111496142234890L, + -3704703351750405709L, + -19193171260619232L, + -6929524759678968876L, + -4050219931171323191L, + -451088895536766085L, + -7199459587351560659L, + -4387638465762062920L, + -872862063775190746L, + -7463067817500576072L, + -4717148753448332186L, + -1284749923383027329L, + -7720497729755473936L, + -5038936143766954516L, + -1686984161281305242L, + -7971894128441897632L, + -5353181642124984136L, + -2079791034228842266L, + -8217398424034108272L, + -5660062011615247436L, + -2463391496091671391L, + -8457148712698376476L, + -5959749872445582690L, + -2838001322129590459L, + -8691279853972075893L, + -6252413799037706962L, + -3203831230369745799L, + -8919923546622172980L, + -6538218414850328321L, + -3561087000135522498L, + -9143208402725783417L, + -6817324484979841367L, + -3909969587797413805L, + -275775966319379352L, + -7089889006590693951L, + -4250675239810979535L, + -701658031336336515L, + -7356065297226292178L, + -4583395603105477318L, + -1117558485454458744L, + -7616003081050118571L, + -4908317832885260309L, + -1523711272679187483L, + -7869848573065574033L, + -5225624697904579637L, + -1920344853953336642L, + -8117744561361917257L, + -5535494683275008668L, + -2307682335666372931L, + -8359830487432564938L, + -5838102090863318268L, + -2685941595151759931L, + -8596242524610931813L, + -6133617137336276862L, + -3055335403242958174L, + -8827113654667930715L, + -6422206049907525489L, + -3416071543957018958L, + -9052573742614218704L, + -6704031159840385477L, + -3768352931373093942L, + -98755145788979523L, + -6979250993759194058L, + -4112377723771604668L, + -528786136287117932L, + -7248020362820530563L, + -4448339435098275300L, + -948738275445456221L, + -7510490449794491994L, + -4776427043815727089L, + -1358847786342270957L, + -7766808894105001204L, + -5096825099203863601L, + -1759345355577441597L, + -8017119874876982854L, + -5409713825168840664L, + -2150456263033662926L, + -8261564192037121185L, + -5715269221619013577L, + -2532400508596379067L, + -8500279345513818773L, + -6013663163464885562L, + -2905392935903719049L, + -8733399612580906261L, + -6305063497298744923L, + -3269643353196043249L, + -8961056123388608887L, + -6589634135808373205L, + -3625356651333078602L, + -9183376934724255982L, + -6867535149977932074L, + -3972732919045027188L, + -354230130378896081L, + -7138922859127891907L, + -4311967555482476979L, + -778273425925708320L, + -7403949918844649556L, + -4643251380128424041L, + -1192378206733142147L, + -7662765406849295698L, + -4966770740134231719L, + -1596777406740401744L, + -7915514906853832946L, + -5282707615139903279L, + -1991698500497491194L, + -8162340590452013853L, + -5591239719637629412L, + -2377363631119648861L, + -8403381297090862394L, + -5892540602936190088L, + -2753989735242849706L, + -8638772612167862923L, + -6186779746782440749L, + -3121788665050663032L, + -8868646943297746251L, + -6474122660694794910L, + -3480967307441105734L, + -9093133594791772939L, + -6754730975062328270L, + -3831727700400522434L, + -177973607073265138L, + -7028762532061872568L, + -4174267146649952805L, + -606147914885053103L, + -7296371474444240045L, + -4508778324627912153L, + -1024286887357502287L, + -7557708332239520785L, + -4835449396872013077L, + -1432625727662628443L, + -7812920107430224633L, + -5154464115860392887L, + -1831394126398103205L, + -8062150356639896359L, + -5466001927372482545L, + -2220816390788215277L, + -8305539271883716404L, + -5770238071427257601L, + -2601111570856684097L, + -8543223759426509417L, + -6067343680855748867L, + -2972493582642298180L, + -8775337516792518218L, + -6357485877563259869L, + -3335171328526686932L, + -9002011107970261189L, + -6640827866535438582L, + -3689348814741910323L, + -9223372036854775808L, + -6917529027641081856L, + -4035225266123964416L, + -432345564227567616L, + -7187745005283311616L, + -4372995238176751616L, + -854558029293551616L, + -7451627795949551616L, + -4702848726509551616L, + -1266874889709551616L, + -7709325833709551616L, + -5024971273709551616L, + -1669528073709551616L, + -7960984073709551616L, + -5339544073709551616L, + -2062744073709551616L, + -8206744073709551616L, + -5646744073709551616L, + -2446744073709551616L, + -8446744073709551616L, + -5946744073709551616L, + -2821744073709551616L, + -8681119073709551616L, + -6239712823709551616L, + -3187955011209551616L, + -8910000909647051616L, + -6525815118631426616L, + -3545582879861895366L, + -9133518327554766460L, + -6805211891016070171L, + -3894828845342699809L, + -256850038250986858L, + -7078060301547948642L, + -4235889358507547899L, + -683175679707046969L, + -7344513827457986212L, + -4568956265895094861L, + -1099509313941480672L, + -7604722348854507276L, + -4894216917640746191L, + -1506085128623544835L, + -7858832233030797378L, + -5211854272861108818L, + -1903131822648998119L, + -8106986416796705680L, + -5522047002568494196L, + -2290872734783229841L, + -8349324486880600507L, + -5824969590173362729L, + -2669525969289315508L, + -8585982758446904048L, + -6120792429631242156L, + -3039304518611664792L, + -8817094351773372351L, + -6409681921289327534L, + -3400416383184271514L, + -9042789267131251552L, + -6691800565486676536L, + -3753064688430957766L, + -79644842111309304L, + -6967307053960650171L, + -4097447799023424810L, + -510123730351893108L, + -7236356359111015049L, + -4433759430461380907L, + -930513269649338229L, + -7499099821171918249L, + -4762188758037509908L, + -1341049929119499481L, + -7755685233340769031L, + -5082920523248573385L, + -1741964635633328828L, + -8006256924911912373L, + -5396135137712502563L, + -2133482903713240299L, + -8250955842461857043L, + -5702008784649933400L, + -2515824962385028846L, + -8489919629131724885L, + -6000713517987268202L, + -2889205879056697348L, + -8723282702051517699L, + -6292417359137009219L, + -3253835680493873620L, + -8951176327949752869L, + -6577284391509803182L, + -3609919470959866073L, + -9173728696990998152L, + -6855474852811359786L, + -3957657547586811828L, + -335385916056126881L, + -7127145225176161157L, + -4297245513042813542L, + -759870872876129023L, + -7392448323188662496L, + -4628874385558440215L, + -1174406963520662365L, + -7651533379841495834L, + -4952730706374481889L, + -1579227364540714457L, + -7904546130479028392L, + -5268996644671397586L, + -1974559787411859078L, + -8151628894773493780L, + -5577850100039479321L, + -2360626606621961247L, + -8392920656779807635L, + -5879464802547371640L, + -2737644984756826646L, + -8628557143114098510L, + -6174010410465235233L, + -3105826994654156138L, + -8858670899299929442L, + -6461652605697523898L, + -3465379738694516969L, + -9083391364325154962L, + -6742553186979055798L, + -3816505465296431844L, + -158945813193151901L, + -7016870160886801794L, + -4159401682681114338L, + -587566084924005019L, + -7284757830718584993L, + -4494261269970843337L, + -1006140569036166267L, + -7546366883288685773L, + -4821272585683469312L, + -1414904713676948736L, + -7801844473689174816L, + -5140619573684080616L, + -1814088448677712866L, + -8051334308064652397L, + -5452481866653427593L, + -2203916314889396587L, + -8294976724446954723L, + -5757034887131305500L, + -2584607590486743971L, + -8532908771695296838L, + -6054449946191733143L, + -2956376414312278525L, + -8765264286586255934L, + -6344894339805432013L, + -3319431906329402113L, + -8992173969096958177L, + -6628531442943809817L, + -3673978285252374367L, + -9213765455923815835L, + -6905520801477381890L, + -4020214983419339459L, + -413582710846786419L, + -7176018221920323368L, + -4358336758973016306L, + -836234930288882479L, + -7440175859071633405L, + -4688533805412153852L, + -1248981238337804411L, + -7698142301602209613L, + -5010991858575374112L, + -1652053804791829737L, + -7950062655635975441L, + -5325892301117581398L, + -2045679357969588843L, + -8196078626372074883L, + -5633412264537705700L, + -2430079312244744221L, + -8436328597794046994L, + -5933724728815170838L, + -2805469892591575644L, + -8670947710510816633L, + -6226998619711132888L, + -3172062256211528206L, + -8900067937773286985L, + -6513398903789220827L, + -3530062611309138129L, + -9123818159709293187L, + -6793086681209228580L, + -3879672333084147821L, + -237904397927796872L, + -7066219276345954901L, + -4221088077005055722L, + -664674077828931748L, + -7332950326284164199L, + -4554501889427817344L, + -1081441343357383777L, + -7593429867239446716L, + -4880101315621920491L, + -1488440626100012710L, + -7847804418953589800L, + -5198069505264599346L, + -1885900863153361278L, + -8096217067111932655L, + -5508585315462527915L, + -2274045625900771989L, + -8338807543829064349L, + -5811823411358942533L, + -2653093245771290262L, + -8575712306248138270L, + -6107954364382784933L, + -3023256937051093262L, + -8807064613298015145L, + -6397144748195131027L, + -3384744916816525880L, + -9032994600651410531L, + -6679557232386875260L, + -3737760522056206171L, + -60514634142869810L, + -6955350673980375487L, + -4082502324048081455L, + -491441886632713914L, + -7224680206786528052L, + -4419164240055772162L, + -912269281642327298L, + -7487697328667536417L, + -4747935642407032618L, + -1323233534581402868L, + -7744549986754458648L, + -5069001465015685407L, + -1724565812842218854L, + -7995382660667468640L, + -5382542307406947896L, + -2116491865831296966L, + -8240336443785642460L, + -5688734536304665171L, + -2499232151953443559L, + -8479549122611984080L, + -5987750384837592197L, + -2873001962619602342L, + -8713155254278333320L, + -6279758049420528746L, + -3238011543348273028L, + -8941286242233752498L, + -6564921784364802719L, + -3594466212028615495L, + -9164070410158966540L, + -6843401994271320271L, + -3942566474411762435L, + -316522074587315140L, + -7115355324258153818L, + -4282508136895304369L, + -741449152691742557L, + -7380934748073420954L, + -4614482416664388289L, + -1156417002403097457L, + -7640289654143017767L, + -4938676049251384304L, + -1561659043136842476L, + -7893565929601608404L, + -5255271393574622601L, + -1957403223540890347L, + -8140906042354138323L, + -5564446534515285000L, + -2343872149716718345L, + -8382449121214030822L, + -5866375383090150623L, + -2721283210435300375L, + -8618331034163144591L, + -6161227774276542834L, + -3089848699418290639L, + -8848684464777513505L, + -6449169562544503977L, + -3449775934753242068L, + -9073638986861858148L, + -6730362715149934781L, + -3801267375510030573L, + -139898200960150312L, + -7004965403241175801L, + -4144520735624081847L, + -568964901102714405L, + -7273132090830278359L, + -4479729095110460045L, + -987975350460687152L, + -7535013621679011326L, + -4807081008671376254L, + -1397165242411832413L, + -7790757304148477114L, + -5126760611758208489L, + -1796764746270372707L, + -8040506994060064798L, + -5438947724147693093L, + -2186998636757228463L, + -8284403175614349645L, + -5743817951090549152L, + -2568086420435798537L, + -8522583040413455941L, + -6041542782089432023L, + -2940242459184402124L, + -8755180564631333184L, + -6332289687361778576L, + -3303676090774835316L, + -8982326584375353928L, + -6616222212041804506L, + -3658591746624867729L, + -9204148869281624187L, + -6893500068174642329L, + -4005189066790915007L, + -394800315061255855L, + -7164279224554366766L, + -4343663012265570553L, + -817892746904575287L, + -7428711994456441410L, + -4674203974643163859L, + -1231068949876566920L, + -7686947121313936181L, + -4996997883215032322L, + -1634561335591402499L, + -7939129862385708418L, + -5312226309554747618L, + -2028596868516046619L, + -8185402070463610993L, + -5620066569652125837L, + -2413397193637769392L, + -8425902273664687726L, }; private static int[] exp10Table = { - 2118, - 2115, - 2111, - 2108, - 2105, - 2101, - 2098, - 2095, - 2091, - 2088, - 2085, - 2081, - 2078, - 2075, - 2071, - 2068, - 2065, - 2061, - 2058, - 2055, - 2052, - 2048, - 2045, - 2042, - 2038, - 2035, - 2032, - 2028, - 2025, - 2022, - 2018, - 2015, - 2012, - 2008, - 2005, - 2002, - 1998, - 1995, - 1992, - 1988, - 1985, - 1982, - 1978, - 1975, - 1972, - 1968, - 1965, - 1962, - 1958, - 1955, - 1952, - 1949, - 1945, - 1942, - 1939, - 1935, - 1932, - 1929, - 1925, - 1922, - 1919, - 1915, - 1912, - 1909, - 1905, - 1902, - 1899, - 1895, - 1892, - 1889, - 1885, - 1882, - 1879, - 1875, - 1872, - 1869, - 1865, - 1862, - 1859, - 1856, - 1852, - 1849, - 1846, - 1842, - 1839, - 1836, - 1832, - 1829, - 1826, - 1822, - 1819, - 1816, - 1812, - 1809, - 1806, - 1802, - 1799, - 1796, - 1792, - 1789, - 1786, - 1782, - 1779, - 1776, - 1772, - 1769, - 1766, - 1762, - 1759, - 1756, - 1753, - 1749, - 1746, - 1743, - 1739, - 1736, - 1733, - 1729, - 1726, - 1723, - 1719, - 1716, - 1713, - 1709, - 1706, - 1703, - 1699, - 1696, - 1693, - 1689, - 1686, - 1683, - 1679, - 1676, - 1673, - 1669, - 1666, - 1663, - 1660, - 1656, - 1653, - 1650, - 1646, - 1643, - 1640, - 1636, - 1633, - 1630, - 1626, - 1623, - 1620, - 1616, - 1613, - 1610, - 1606, - 1603, - 1600, - 1596, - 1593, - 1590, - 1586, - 1583, - 1580, - 1576, - 1573, - 1570, - 1567, - 1563, - 1560, - 1557, - 1553, - 1550, - 1547, - 1543, - 1540, - 1537, - 1533, - 1530, - 1527, - 1523, - 1520, - 1517, - 1513, - 1510, - 1507, - 1503, - 1500, - 1497, - 1493, - 1490, - 1487, - 1483, - 1480, - 1477, - 1473, - 1470, - 1467, - 1464, - 1460, - 1457, - 1454, - 1450, - 1447, - 1444, - 1440, - 1437, - 1434, - 1430, - 1427, - 1424, - 1420, - 1417, - 1414, - 1410, - 1407, - 1404, - 1400, - 1397, - 1394, - 1390, - 1387, - 1384, - 1380, - 1377, - 1374, - 1371, - 1367, - 1364, - 1361, - 1357, - 1354, - 1351, - 1347, - 1344, - 1341, - 1337, - 1334, - 1331, - 1327, - 1324, - 1321, - 1317, - 1314, - 1311, - 1307, - 1304, - 1301, - 1297, - 1294, - 1291, - 1287, - 1284, - 1281, - 1277, - 1274, - 1271, - 1268, - 1264, - 1261, - 1258, - 1254, - 1251, - 1248, - 1244, - 1241, - 1238, - 1234, - 1231, - 1228, - 1224, - 1221, - 1218, - 1214, - 1211, - 1208, - 1204, - 1201, - 1198, - 1194, - 1191, - 1188, - 1184, - 1181, - 1178, - 1175, - 1171, - 1168, - 1165, - 1161, - 1158, - 1155, - 1151, - 1148, - 1145, - 1141, - 1138, - 1135, - 1131, - 1128, - 1125, - 1121, - 1118, - 1115, - 1111, - 1108, - 1105, - 1101, - 1098, - 1095, - 1091, - 1088, - 1085, - 1082, - 1078, - 1075, - 1072, - 1068, - 1065, - 1062, - 1058, - 1055, - 1052, - 1048, - 1045, - 1042, - 1038, - 1035, - 1032, - 1028, - 1025, - 1022, - 1018, - 1015, - 1012, - 1008, - 1005, - 1002, - 998, - 995, - 992, - 988, - 985, - 982, - 979, - 975, - 972, - 969, - 965, - 962, - 959, - 955, - 952, - 949, - 945, - 942, - 939, - 935, - 932, - 929, - 925, - 922, - 919, - 915, - 912, - 909, - 905, - 902, - 899, - 895, - 892, - 889, - 886, - 882, - 879, - 876, - 872, - 869, - 866, - 862, - 859, - 856, - 852, - 849, - 846, - 842, - 839, - 836, - 832, - 829, - 826, - 822, - 819, - 816, - 812, - 809, - 806, - 802, - 799, - 796, - 792, - 789, - 786, - 783, - 779, - 776, - 773, - 769, - 766, - 763, - 759, - 756, - 753, - 749, - 746, - 743, - 739, - 736, - 733, - 729, - 726, - 723, - 719, - 716, - 713, - 709, - 706, - 703, - 699, - 696, - 693, - 690, - 686, - 683, - 680, - 676, - 673, - 670, - 666, - 663, - 660, - 656, - 653, - 650, - 646, - 643, - 640, - 636, - 633, - 630, - 626, - 623, - 620, - 616, - 613, - 610, - 606, - 603, - 600, - 596, - 593, - 590, - 587, - 583, - 580, - 577, - 573, - 570, - 567, - 563, - 560, - 557, - 553, - 550, - 547, - 543, - 540, - 537, - 533, - 530, - 527, - 523, - 520, - 517, - 513, - 510, - 507, - 503, - 500, - 497, - 494, - 490, - 487, - 484, - 480, - 477, - 474, - 470, - 467, - 464, - 460, - 457, - 454, - 450, - 447, - 444, - 440, - 437, - 434, - 430, - 427, - 424, - 420, - 417, - 414, - 410, - 407, - 404, - 401, - 397, - 394, - 391, - 387, - 384, - 381, - 377, - 374, - 371, - 367, - 364, - 361, - 357, - 354, - 351, - 347, - 344, - 341, - 337, - 334, - 331, - 327, - 324, - 321, - 317, - 314, - 311, - 307, - 304, - 301, - 298, - 294, - 291, - 288, - 284, - 281, - 278, - 274, - 271, - 268, - 264, - 261, - 258, - 254, - 251, - 248, - 244, - 241, - 238, - 234, - 231, - 228, - 224, - 221, - 218, - 214, - 211, - 208, - 205, - 201, - 198, - 195, - 191, - 188, - 185, - 181, - 178, - 175, - 171, - 168, - 165, - 161, - 158, - 155, - 151, - 148, - 145, - 141, - 138, - 135, - 131, - 128, - 125, - 121, - 118, - 115, - 111, - 108, - 105, - 102, - 98, - 95, - 92, - 88, - 85, - 82, - 78, - 75, - 72, - 68, - 65, - 62, - 58, - 55, - 52, - 48, - 45, - 42, - 38, - 35, - 32, - 28, - 25, - 22, - 18, - 15, - 12, - 9, - 5, - 2, - -1, - -5, - -8, - -11, - -15, - -18, - -21, - -25, - -28, - -31, - -35, - -38, - -41, - -45, - -48, - -51, - -55, - -58, - -61, - -65, - -68, - -71, + -76, + -72, + -69, + -66, + -62, + -59, + -56, + -52, + -49, + -46, + -42, + -39, + -36, + -32, + -29, + -26, + -22, + -19, + -16, + -12, + -9, + -6, + -2, + 1, + 4, + 8, + 11, + 14, + 17, + 21, + 24, + 27, + 31, + 34, + 37, + 41, + 44, + 47, + 51, + 54, + 57, + 61, + 64, + 67, + 71, + 74, + 77, + 81, + 84, + 87, + 91, + 94, + 97, + 101, + 104, + 107, + 110, + 114, + 117, + 120, + 124, + 127, + 130, + 134, + 137, + 140, + 144, + 147, + 150, + 154, + 157, + 160, + 164, + 167, + 170, + 174, + 177, + 180, + 184, + 187, + 190, + 194, + 197, + 200, + 204, + 207, + 210, + 213, + 217, + 220, + 223, + 227, + 230, + 233, + 237, + 240, + 243, + 247, + 250, + 253, + 257, + 260, + 263, + 267, + 270, + 273, + 277, + 280, + 283, + 287, + 290, + 293, + 297, + 300, + 303, + 306, + 310, + 313, + 316, + 320, + 323, + 326, + 330, + 333, + 336, + 340, + 343, + 346, + 350, + 353, + 356, + 360, + 363, + 366, + 370, + 373, + 376, + 380, + 383, + 386, + 390, + 393, + 396, + 400, + 403, + 406, + 409, + 413, + 416, + 419, + 423, + 426, + 429, + 433, + 436, + 439, + 443, + 446, + 449, + 453, + 456, + 459, + 463, + 466, + 469, + 473, + 476, + 479, + 483, + 486, + 489, + 493, + 496, + 499, + 502, + 506, + 509, + 512, + 516, + 519, + 522, + 526, + 529, + 532, + 536, + 539, + 542, + 546, + 549, + 552, + 556, + 559, + 562, + 566, + 569, + 572, + 576, + 579, + 582, + 586, + 589, + 592, + 595, + 599, + 602, + 605, + 609, + 612, + 615, + 619, + 622, + 625, + 629, + 632, + 635, + 639, + 642, + 645, + 649, + 652, + 655, + 659, + 662, + 665, + 669, + 672, + 675, + 679, + 682, + 685, + 689, + 692, + 695, + 698, + 702, + 705, + 708, + 712, + 715, + 718, + 722, + 725, + 728, + 732, + 735, + 738, + 742, + 745, + 748, + 752, + 755, + 758, + 762, + 765, + 768, + 772, + 775, + 778, + 782, + 785, + 788, + 791, + 795, + 798, + 801, + 805, + 808, + 811, + 815, + 818, + 821, + 825, + 828, + 831, + 835, + 838, + 841, + 845, + 848, + 851, + 855, + 858, + 861, + 865, + 868, + 871, + 875, + 878, + 881, + 885, + 888, + 891, + 894, + 898, + 901, + 904, + 908, + 911, + 914, + 918, + 921, + 924, + 928, + 931, + 934, + 938, + 941, + 944, + 948, + 951, + 954, + 958, + 961, + 964, + 968, + 971, + 974, + 978, + 981, + 984, + 987, + 991, + 994, + 997, + 1001, + 1004, + 1007, + 1011, + 1014, + 1017, + 1021, + 1024, + 1027, + 1031, + 1034, + 1037, + 1041, + 1044, + 1047, + 1051, + 1054, + 1057, + 1061, + 1064, + 1067, + 1071, + 1074, + 1077, + 1081, + 1084, + 1087, + 1090, + 1094, + 1097, + 1100, + 1104, + 1107, + 1110, + 1114, + 1117, + 1120, + 1124, + 1127, + 1130, + 1134, + 1137, + 1140, + 1144, + 1147, + 1150, + 1154, + 1157, + 1160, + 1164, + 1167, + 1170, + 1174, + 1177, + 1180, + 1183, + 1187, + 1190, + 1193, + 1197, + 1200, + 1203, + 1207, + 1210, + 1213, + 1217, + 1220, + 1223, + 1227, + 1230, + 1233, + 1237, + 1240, + 1243, + 1247, + 1250, + 1253, + 1257, + 1260, + 1263, + 1267, + 1270, + 1273, + 1276, + 1280, + 1283, + 1286, + 1290, + 1293, + 1296, + 1300, + 1303, + 1306, + 1310, + 1313, + 1316, + 1320, + 1323, + 1326, + 1330, + 1333, + 1336, + 1340, + 1343, + 1346, + 1350, + 1353, + 1356, + 1360, + 1363, + 1366, + 1370, + 1373, + 1376, + 1379, + 1383, + 1386, + 1389, + 1393, + 1396, + 1399, + 1403, + 1406, + 1409, + 1413, + 1416, + 1419, + 1423, + 1426, + 1429, + 1433, + 1436, + 1439, + 1443, + 1446, + 1449, + 1453, + 1456, + 1459, + 1463, + 1466, + 1469, + 1472, + 1476, + 1479, + 1482, + 1486, + 1489, + 1492, + 1496, + 1499, + 1502, + 1506, + 1509, + 1512, + 1516, + 1519, + 1522, + 1526, + 1529, + 1532, + 1536, + 1539, + 1542, + 1546, + 1549, + 1552, + 1556, + 1559, + 1562, + 1566, + 1569, + 1572, + 1575, + 1579, + 1582, + 1585, + 1589, + 1592, + 1595, + 1599, + 1602, + 1605, + 1609, + 1612, + 1615, + 1619, + 1622, + 1625, + 1629, + 1632, + 1635, + 1639, + 1642, + 1645, + 1649, + 1652, + 1655, + 1659, + 1662, + 1665, + 1668, + 1672, + 1675, + 1678, + 1682, + 1685, + 1688, + 1692, + 1695, + 1698, + 1702, + 1705, + 1708, + 1712, + 1715, + 1718, + 1722, + 1725, + 1728, + 1732, + 1735, + 1738, + 1742, + 1745, + 1748, + 1752, + 1755, + 1758, + 1761, + 1765, + 1768, + 1771, + 1775, + 1778, + 1781, + 1785, + 1788, + 1791, + 1795, + 1798, + 1801, + 1805, + 1808, + 1811, + 1815, + 1818, + 1821, + 1825, + 1828, + 1831, + 1835, + 1838, + 1841, + 1845, + 1848, + 1851, + 1855, + 1858, + 1861, + 1864, + 1868, + 1871, + 1874, + 1878, + 1881, + 1884, + 1888, + 1891, + 1894, + 1898, + 1901, + 1904, + 1908, + 1911, + 1914, + 1918, + 1921, + 1924, + 1928, + 1931, + 1934, + 1938, + 1941, + 1944, + 1948, + 1951, + 1954, + 1957, + 1961, + 1964, + 1967, + 1971, + 1974, + 1977, + 1981, + 1984, + 1987, + 1991, + 1994, + 1997, + 2001, + 2004, + 2007, + 2011, + 2014, + 2017, + 2021, + 2024, + 2027, + 2031, + 2034, + 2037, + 2041, + 2044, + 2047, + 2051, + 2054, + 2057, + 2060, + 2064, + 2067, + 2070, + 2074, + 2077, + 2080, + 2084, + 2087, + 2090, + 2094, + 2097, + 2100, + 2104, + 2107, + 2110, + 2114, }; } diff --git a/classlib/src/main/java/org/teavm/classlib/impl/text/DoubleSynthesizerGenerator.java b/classlib/src/main/java/org/teavm/classlib/impl/text/DoubleSynthesizerGenerator.java index 83e2176f2..ca904e5c9 100644 --- a/classlib/src/main/java/org/teavm/classlib/impl/text/DoubleSynthesizerGenerator.java +++ b/classlib/src/main/java/org/teavm/classlib/impl/text/DoubleSynthesizerGenerator.java @@ -24,29 +24,26 @@ public final class DoubleSynthesizerGenerator { public static void main(String[] args) { var mantissaList = new long[660]; var expList = new long[660]; - var shift = 122; - var exp = 0; + var binOneShift = 1024 + 256; + var binOne = BigInteger.ONE.shiftLeft(binOneShift); var dec = BigInteger.valueOf(1000000000000000000L); - for (var i = 0; i < 330; ++i) { - while (BigInteger.ONE.shiftLeft(shift + exp + 1).divide(dec).bitLength() <= 64) { - ++exp; - } - mantissaList[330 + i] = BigInteger.ONE.shiftLeft(shift + exp).divide(dec).longValue(); + for (var i = 0; i <= 330; ++i) { + var quot = binOne.divide(dec); + mantissaList[330 - i] = extractLong(quot); + var exp = quot.bitLength() - binOneShift + 57; + expList[330 - i] = 1023 + exp; dec = dec.multiply(BigInteger.valueOf(10)); - expList[330 + i] = 1023 - exp; } - exp = 1; - dec = BigInteger.valueOf(1000000000000000000L).multiply(BigInteger.ONE.shiftLeft(1024)); - var q = BigInteger.valueOf(10L); - for (var i = 1; i <= 330; ++i) { - while (BigInteger.ONE.shiftLeft(shift + 1024 - exp).multiply(q).divide(dec).bitLength() > 64) { - ++exp; - } - mantissaList[330 - i] = BigInteger.ONE.shiftLeft(shift + 1024 - exp).multiply(q).divide(dec).longValue(); - q = q.multiply(BigInteger.valueOf(10)); - expList[330 - i] = 1023 + exp; + dec = BigInteger.valueOf(1000000000000000000L); + var q = BigInteger.TEN; + for (var i = 1; i < 330; ++i) { + var quot = q.shiftLeft(binOneShift).divide(dec); + mantissaList[330 + i] = extractLong(quot); + var exp = quot.bitLength() - binOneShift + 57; + expList[330 + i] = 1023 + exp; + q = q.multiply(BigInteger.TEN); } System.out.println("[mantissa]"); @@ -60,4 +57,8 @@ public final class DoubleSynthesizerGenerator { System.out.println(value + ","); } } + + private static long extractLong(BigInteger n) { + return n.shiftRight(n.bitLength() - 65).add(BigInteger.ONE).shiftRight(1).longValue(); + } }