View Issue Details

IDProjectCategoryView StatusLast Update
0029531FPCRTLpublic2020-05-02 21:15
ReporterBenito van der Zander Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status newResolutionreopened 
Product Version3.1.1 
Summary0029531: string to double conversion rounded wrong
DescriptionThe string to double conversion with Val is wrong by one unit for several numbers.

The a.i.sections lists for some samples the decimal input, converted/expected double as raw hexadecimal, and respective difference to the input
Additional InformationConverting 1.584563250377521E29 to double
got: 4600000000040002 = 1.5845632503775212E+029
       = 1.58456325037752117592686854144E29
       = 1.584563250377521E29 + 1.7592686854144E13
expected: 4600000000040001 = 1.5845632503775208E+029
       = 1.58456325037752082408314765312E29
       = 1.584563250377521E29 - 1.7591685234688E13

Converting 3.169126500755042E29 to double
got: 4610000000040002 = 3.1691265007550424E+029
       = 3.16912650075504235185373708288E29
       = 3.169126500755042E29 + 3.5185373708288E13
expected: 4610000000040001 = 3.1691265007550416E+029
       = 3.16912650075504164816629530624E29
       = 3.169126500755042E29 - 3.5183370469376E13

Converting 2.854495725694287E45 to double
got: 4960000020000000 = 2.8544957256942867E+045
       = 2.854495725694286683055035402273597704533704704E45
       = 2.854495725694287E45 - 3.16944964597726402295466295296E29
expected: 4960000020000001 = 2.8544957256942873E+045
       = 2.854495725694287316880335516388298452885307392E45
       = 2.854495725694287E45 + 3.16880335516388298452885307392E29

Converting 2.208559357534439E71 to double
got: 4EC0000040000000 = 2.2085593575344388E+071
       = 2.2085593575344387547650553655187865631365164655700007003975640231706624E71
       = 2.208559357534439E71 - 2.452349446344812134368634835344299992996024359768293376E55
expected: 4EC0000040000001 = 2.2085593575344392E+071
       = 2.20855935753443924516362844260322123780756515366893945839408312192335872E71
       = 2.208559357534439E71 + 2.4516362844260322123780756515366893945839408312192335872E55

Converting 4.417118715068878E71 to double
got: 4ED0000040000000 = 4.4171187150688775E+071
       = 4.4171187150688775095301107310375731262730329311400014007951280463413248E71
       = 4.417118715068878E71 - 4.904698892689624268737269670688599985992048719536586752E55
expected: 4ED0000040000001 = 4.4171187150688785E+071
       = 4.41711871506887849032725688520644247561513030733787891678816624384671744E71
       = 4.417118715068878E71 + 4.9032725688520644247561513030733787891678816624384671744E55

Converting 4.383627059105937E-193 to double
got: 1800000200000000 = 4.3836270591059365E-193
       = 4.383627059105936513171767106818813706280418678717380665508158102144268102083093232708031862420351280561109742532277464499635180124794724328516343536367550947239723489015479624018459607685423301622476472485681463789715704668024157153688470166252846556788200689876929264389001242114216315679625307911109790990902538348217336650122813173327010733721178193698438196917626253254220609912158235864448125743347238993169216826457598203126142522023656056262552738189697265625E-193
       = 4.383627059105937E-193 - 4.86828232893181186293719581321282619334491841897855731897916906767291968137579648719438890257467722535500364819875205275671483656463632449052760276510984520375981540392314576698377523527514318536210284295331975842846311529833747153443211799310123070735610998757885783684320374692088890209009097461651782663349877186826672989266278821806301561803082373746745779390087841764135551874256652761006830783173542401796873857477976343943737447261810302734375E-209
expected: 1800000200000001 = 4.3836270591059375E-193
       = 4.383627059105937486530649049940643345997490466290172609122215765386012712257074706425407492486119501848276233474671424236277485813467325814986714756142784762087510421509804456196165095933534872749616509500864998983888251248610537637354492035747196137852097689125817210117217580729830472839264761121743187906605472219024112961180789566158650826866730315838804989693338402720671512199832226344572527237358384466909893900310267542038413912065872082421233676724665884183451680655707605183124542236328125E-193
       = 4.383627059105937E-193 + 4.86530649049940643345997490466290172609122215765386012712257074706425407492486119501848276233474671424236277485813467325814986714756142784762087510421509804456196165095933534872749616509500864998983888251248610537637354492035747196137852097689125817210117217580729830472839264761121743187906605472219024112961180789566158650826866730315838804989693338402720671512199832226344572527237358384466909893900310267542038413912065872082421233676724665884183451680655707605183124542236328125E-209

Converting 1.957195664071263E-294 to double
got: 2F4000000000002 = 1.9571956640712632E-294
       = 1.9571956640712631738474050523970748405945467273175902957564713656104886472014876005987843202034117540391165437320532723389024240350735908550423605502971418108023772278504524689155323003447142726353384922817552469816334044709617390813719270987255242414614852017648119439175457500057135094450347560813358671953757189317827026152681059616196616435934358456974599730941477883412437166462618630854049541702780996771466030544021620624679991520733092017505399356287966767467610292888774554988962980951317919422251332587165380590357292990882325339588377164034935381219543648238326690622174484419175554789035940721883730397602351999053663366069294184788920136028004303697064920733692004039742402194995869735283378076928784139454364776611328125E-294
       = 1.957195664071263E-294 + 1.738474050523970748405945467273175902957564713656104886472014876005987843202034117540391165437320532723389024240350735908550423605502971418108023772278504524689155323003447142726353384922817552469816334044709617390813719270987255242414614852017648119439175457500057135094450347560813358671953757189317827026152681059616196616435934358456974599730941477883412437166462618630854049541702780996771466030544021620624679991520733092017505399356287966767467610292888774554988962980951317919422251332587165380590357292990882325339588377164034935381219543648238326690622174484419175554789035940721883730397602351999053663366069294184788920136028004303697064920733692004039742402194995869735283378076928784139454364776611328125E-310
expected: 2F4000000000001 = 1.9571956640712628E-294
       = 1.95719566407126282617961466064685873274568464412945526150397441837114012324407871197309138052869365180737294802720630920338059106072812129997452280756899980205044201258188666723147081096935013519625295437806211074388886588619553061131329416018636538862414946418806507382510205492748914869970377094464840143166419550218089316970481675608843405258237043239846967062461777021919906570063804537413708660931735034908260441551284909486776304840669773399062156273613583740894113465891159836384147432593981731065562594443409838536743823632419296456664644117733391022083465380193356201773045580099518652221939145817159598923928410787674523225710958627689607954454126479862194654694804319515118260974979348676416890384643920697271823883056640625E-294
       = 1.957195664071263E-294 - 1.7382038533935314126725431535587054473849602558162885987675592128802690861947130634819262705197279369079661940893927187870002547719243100019794955798741811333276852918903064986480374704562193788925611113411380446938868670583981363461137585053581193492617489794507251085130029622905535159856833580449781910683029518324391156594741762956760153032937538222978080093429936195462586291339068264965091739558448715090513223695159330226600937843726386416259105886534108840163615852567406018268934437405556590161463256176367580703543335355882266608977916534619806643798226954419900481347778060854182840401076071589212325476774289041372310392045545873520137805345305195680484881739025020651323583109615356079302728176116943359375E-310

Converting 3.914391328142526E-294 to double
got: 304000000000002 = 3.9143913281425263E-294
       = 3.914391328142526347694810104794149681189093454635180591512942731220977294402975201197568640406823508078233087464106544677804848070147181710084721100594283621604754455700904937831064600689428545270676984563510493963266808941923478162743854197451048482922970403529623887835091500011427018890069512162671734390751437863565405230536211923239323287186871691394919946188295576682487433292523726170809908340556199354293206108804324124935998304146618403501079871257593353493522058577754910997792596190263583884450266517433076118071458598176465067917675432806987076243908729647665338124434896883835110957807188144376746079520470399810732673213858836957784027205600860739412984146738400807948480438999173947056675615385756827890872955322265625E-294
       = 3.914391328142526E-294 + 3.47694810104794149681189093454635180591512942731220977294402975201197568640406823508078233087464106544677804848070147181710084721100594283621604754455700904937831064600689428545270676984563510493963266808941923478162743854197451048482922970403529623887835091500011427018890069512162671734390751437863565405230536211923239323287186871691394919946188295576682487433292523726170809908340556199354293206108804324124935998304146618403501079871257593353493522058577754910997792596190263583884450266517433076118071458598176465067917675432806987076243908729647665338124434896883835110957807188144376746079520470399810732673213858836957784027205600860739412984146738400807948480438999173947056675615385756827890872955322265625E-310
expected: 304000000000001 = 3.9143913281425257E-294
       = 3.9143913281425256523592293212937174654913692882589105230079488367422802464881574239461827610573873036147458960544126184067611821214562425999490456151379996041008840251637733344629416219387002703925059087561242214877777317723910612226265883203727307772482989283761301476502041098549782973994075418892968028633283910043617863394096335121768681051647408647969393412492355404383981314012760907482741732186347006981652088310256981897355260968133954679812431254722716748178822693178231967276829486518796346213112518888681967707348764726483859291332928823546678204416693076038671240354609116019903730444387829163431919784785682157534904645142191725537921590890825295972438930938960863903023652194995869735283378076928784139454364776611328125E-294
       = 3.914391328142526E-294 - 3.476407706787062825345086307117410894769920511632577197535118425760538172389426126963852541039455873815932388178785437574000509543848620003958991159748362266655370583780612997296074940912438757785122222682276089387773734116796272692227517010716238698523497958901450217026005924581107031971366716089956382136605903664878231318948352591352030606587507644595616018685987239092517258267813652993018347911689743018102644739031866045320187568745277283251821177306821768032723170513481203653786887481111318032292651235273516140708667071176453321795583306923961328759645390883980096269555612170836568080215214317842465095354857808274462078409109174704027561069061039136096976347805004130264716621923071215860545635223388671875E-310

Converting 1.250000000004549E-1 to double
got: 3FC0000000004006 = 1.2500000000045491E-001
       = 1.25000000000454913884340157892438583076000213623046875E-1
       = 1.250000000004549E-1 + 1.3884340157892438583076000213623046875E-17
expected: 3FC0000000004005 = 1.2500000000045489E-001
       = 1.250000000004548861287645422635250724852085113525390625E-1
       = 1.250000000004549E-1 - 1.38712354577364749275147914886474609375E-17

Converting 2.500000000009098E-1 to double
got: 3FD0000000004006 = 2.5000000000090983E-001
       = 2.5000000000090982776868031578487716615200042724609375E-1
       = 2.500000000009098E-1 + 2.776868031578487716615200042724609375E-17
expected: 3FD0000000004005 = 2.5000000000090977E-001
       = 2.50000000000909772257529084527050144970417022705078125E-1
       = 2.500000000009098E-1 - 2.7742470915472949855029582977294921875E-17

Converting 5.68434222621747E-14 to double
got: 3D30000010100000 = 5.6843422262174694E-014
       = 5.68434222621746936877397404774825417916872538626194000244140625E-14
       = 5.68434222621747E-14 - 6.3122602595225174582083127461373805999755859375E-30
expected: 3D30000010100001 = 5.6843422262174706E-014
       = 5.6843422262174706309514224013671428379344298387199074795717024244368076324462890625E-14
       = 5.68434222621747E-14 + 6.309514224013671428379344298387199074795717024244368076324462890625E-30

Converting 1.136868445243494E-13 to double
got: 3D40000010100000 = 1.1368684452434939E-013
       = 1.13686844524349387375479480954965083583374507725238800048828125E-13
       = 1.136868445243494E-13 - 1.2624520519045034916416625492274761199951171875E-29
expected: 3D40000010100001 = 1.1368684452434941E-013
       = 1.1368684452434941261902844802734285675868859677439814959143404848873615264892578125E-13
       = 1.136868445243494E-13 + 1.261902844802734285675868859677439814959143404848873615264892578125E-29

Converting 2.273736890486988E-13 to double
got: 3D50000010100000 = 2.2737368904869877E-013
       = 2.2737368904869877475095896190993016716674901545047760009765625E-13
       = 2.273736890486988E-13 - 2.524904103809006983283325098454952239990234375E-29
expected: 3D50000010100001 = 2.2737368904869883E-013
       = 2.273736890486988252380568960546857135173771935487962991828680969774723052978515625E-13
       = 2.273736890486988E-13 + 2.52380568960546857135173771935487962991828680969774723052978515625E-29

Converting 3.835229384285829E-93 to double
got: 2CC0000008040002 = 3.8352293842858294E-093
       = 3.8352293842858294258773253971356908649083564693976849245257854571062299392900378412973373415126832295180709706871815599655466936277641748338640023334863828102969593329931062337379201964058202866034104725705938942714699554253389435221066605663509108126163482666015625E-93
       = 3.835229384285829E-93 + 4.258773253971356908649083564693976849245257854571062299392900378412973373415126832295180709706871815599655466936277641748338640023334863828102969593329931062337379201964058202866034104725705938942714699554253389435221066605663509108126163482666015625E-109
expected: 2CC0000008040001 = 3.8352293842858286E-093
       = 3.83522938428582857428535739550554688289761321993591527520643859496990975428001947201557159240225597251069422521580117034737765907665909859494766314175252249190273542686258227976813061981183934210713669944278013361260540697275818466938090978146647103130817413330078125E-93
       = 3.835229384285829E-93 - 4.2571464260449445311710238678006408472479356140503009024571998052798442840759774402748930577478419882965262234092334090140505233685824747750809726457313741772023186938018816065789286330055721986638739459302724181533061909021853352896869182586669921875E-109

Converting 3.009265630590755E-36 to double
got: 3890000008400000 = 3.0092656305907547E-036
       = 3.0092656305907546658378922162551014323502484898338322189124453040392549209303130197667996981181204319000244140625E-36
       = 3.009265630590755E-36 - 3.341621077837448985676497515101661677810875546959607450790696869802332003018818795680999755859375E-52
expected: 3890000008400001 = 3.0092656305907553E-036
       = 3.00926563059075533402906973930401296748436527770430192271166533030142941141468605986645994490071009952458780389861203730106353759765625E-36
       = 3.009265630590755E-36 + 3.3402906973930401296748436527770430192271166533030142941141468605986645994490071009952458780389861203730106353759765625E-52

Converting 6.000600000008E265 to double
got: 771DC68491C306E0 = 6.0006000000079996E+265
       = 6.0006000000079996419633213294020797932660853962444463132109473916934555388879127952794685430256154422683369315040504881622410915960375353636015048502013140888275863713393522717978268803567152448554998085022724982826797365190625640527489549130862202438140156975251456E265
       = 6.000600000008E265 - 3.580366786705979202067339146037555536867890526083065444611120872047205314569743845577316630684959495118377589084039624646363984951497986859111724136286606477282021731196432847551445001914977275017173202634809374359472510450869137797561859843024748544E249
expected: 771DC68491C306E1 = 6.0006000000080004E+265
       = 6.000600000008000357935919291276109903735683738115408581254426695959768774924155353056068676848219425900443577119759873896228822071030537223523023777035731599953237410453842784619684579837017801525531345476741904408679942312693750951012795081525810627783693359382528E265
       = 6.000600000008E265 + 3.57935919291276109903735683738115408581254426695959768774924155353056068676848219425900443577119759873896228822071030537223523023777035731599953237410453842784619684579837017801525531345476741904408679942312693750951012795081525810627783693359382528E249

Converting 8.007E248 to double
got: 739CA1254F8DF33C = 8.0070000000000005E+248
       = 8.00700000000000049696509632360754838974926774616526222792063060428553714467951006388641028636692850119100687453043188795773083796380869496310955835586741855870517293199066081252808403025126591859011432108557543704050894970326650555236079694644248576E248
       = 8.007E248 + 4.9696509632360754838974926774616526222792063060428553714467951006388641028636692850119100687453043188795773083796380869496310955835586741855870517293199066081252808403025126591859011432108557543704050894970326650555236079694644248576E232
expected: 739CA1254F8DF33B = 8.0069999999999995E+248
       = 8.00699999999999950335351725115382989440239513016362686351357964959970601568620572721380056708572124942882522419668599964558319179992184301329833012238620803436131690563473172167689937690732636642033151686257074887218946572472650498093881050416545792E248
       = 8.007E248 - 4.9664648274884617010559760486983637313648642035040029398431379427278619943291427875057117477580331400035441680820007815698670166987761379196563868309436526827832310062309267363357966848313742925112781053427527349501906118949583454208E232

Converting 6.0000000002E299 to double
got: 7E2CAB7BD66B0E4A = 6.0000000001999996E+299
       = 6.00000000019999962816809791982367250404047866228492903283770826963043889569586524528433115751139168705701620368257942801526472370852957380563880629170098523775685197554338705155464341343439803441969726212566136078562563548371033927827687069489772030365562619911121208757696001067623628931228497870848E299
       = 6.0000000002E299 - 3.7183190208017632749595952133771507096716229173036956110430413475471566884248860831294298379631742057198473527629147042619436119370829901476224314802445661294844535658656560196558030273787433863921437436451628966072172312930510227969634437380088878791242303998932376371068771502129152E283
expected: 7E2CAB7BD66B0E4B = 6.0000000002000004E+299
       = 6.00000000020000037167655215871520390307172773723520909846780909932766842358179490325465973771357845964117345176075472291462661880501609903293142906415383913317214252674069994304006363716433500576290217927452979590522352665942894231215122413383776438220509637344025359359951273774819270119495938605056E299
       = 6.0000000002E299 + 3.7167655215871520390307172773723520909846780909932766842358179490325465973771357845964117345176075472291462661880501609903293142906415383913317214252674069994304006363716433500576290217927452979590522352665942894231215122413383776438220509637344025359359951273774819270119495938605056E283

Converting 8.0000000002E285 to double
got: 7B4AE64521FA3CC6 = 8.0000000001999995E+285
       = 8.000000000199999471692478970466626187959431349652256839701656425854317733240786781127023599889558937819214902742185856739921877910247713193267506011591962716785567784577654574933154715878282028000571059245851892901514171270056669620544257969049761284130386310628152200811003009262682112E285
       = 8.0000000002E285 - 5.28307521029533373812040568650347743160298343574145682266759213218872976400110441062180785097257814143260078122089752286806732493988408037283214432215422345425066845284121717971999428940754148107098485828729943330379455742030950238715869613689371847799188996990737317888E269
expected: 7B4AE64521FA3CC7 = 8.0000000002000005E+285
       = 8.000000000200000528281541241797118892639001182685469877396308498097361989162204834474828713339277886653726678056561646088711864424505070957962625016963037217863524710456808391706522713888450365463606412098733998949979987692433477916600843472173238960924183844701105179888164804738678784E285
       = 8.0000000002E285 + 5.28281541241797118892639001182685469877396308498097361989162204834474828713339277886653726678056561646088711864424505070957962625016963037217863524710456808391706522713888450365463606412098733998949979987692433477916600843472173238960924183844701105179888164804738678784E269

Converting 5.000000000400007E160 to double
got: 614C73892ED5C29A = 5.0000000004000073E+160
       = 5.0000000004000073122733360953041641433060678045883289188235910834068420243927113355004696555762020186231787700879335703036217253632848735829420703003260814884864E160
       = 5.000000000400007E160 + 3.122733360953041641433060678045883289188235910834068420243927113355004696555762020186231787700879335703036217253632848735829420703003260814884864E144
expected: 614C73892ED5C299 = 5.0000000004000067E+160
       = 5.0000000004000066879236260321057178669866218459550677691039625504126118525613194104261218916230779945619581573895393383382355010819602944933469344426690202304512E160
       = 5.000000000400007E160 - 3.120763739678942821330133781540449322308960374495873881474386805895738781083769220054380418426104606616617644989180397055066530655573309797695488E144

Converting 9.005E275 to double
got: 793A025D96FF0A08 = 9.0050000000000006E+275
       = 9.00500000000000061525636821678203924258117438619359277729499076316939828944692781847255126877970391300575774041669842835959600585917726674973035532704469203649183777222201086308874747447948949290097098754194136607233890947180173760785920236476906124459514359878323804458450944E275
       = 9.005E275 + 6.1525636821678203924258117438619359277729499076316939828944692781847255126877970391300575774041669842835959600585917726674973035532704469203649183777222201086308874747447948949290097098754194136607233890947180173760785920236476906124459514359878323804458450944E259
expected: 793A025D96FF0A07 = 9.0049999999999994E+275
       = 9.00499999999999938522481098541995356410669755395694861997629895601873884013989163592299604924478088290207080501520499013250550263703427122283831656008515602949408282833994944217988847718601122206778214170435701156685373380263546848237645328364139242428080431344755643491811328E275
       = 9.005E275 - 6.1477518901458004643589330244604305138002370104398126115986010836407700395075521911709792919498479500986749449736296572877716168343991484397050591717166005055782011152281398877793221785829564298843314626619736453151762354671635860757571919568655244356508188672E259

Converting 4.000000000006E257 to double
got: 756AA3D4DF50DAFA = 4.0000000000059997E+257
       = 4.00000000000599973317676757824381609900916551801433948307651888113949467043929774142954821770925517811003156175732998988822328403916910228693030844790699572775311101233996009908790235236404096340821838589469428487817496629014029403402596480648189654876553216E257
       = 4.000000000006E257 - 2.6682323242175618390099083448198566051692348111886050532956070225857045178229074482188996843824267001011177671596083089771306969155209300427224688898766003990091209764763595903659178161410530571512182503370985970596597403519351810345123446784E241
expected: 756AA3D4DF50DAFB = 4.0000000000060003E+257
       = 4.00000000000600026661792220863215802539730877571496325465718466641214750213992268255252724311982089982460763148167324932261613151382833795803444077745620215682159519880636378670050871348520564045448125883981626319537625716106845256928580780459879984187572224E257
       = 4.000000000006E257 + 2.6661792220863215802539730877571496325465718466641214750213992268255252724311982089982460763148167324932261613151382833795803444077745620215682159519880636378670050871348520564045448125883981626319537625716106845256928580780459879984187572224E241

Converting 4.00000004E127 to double
got: 5A6D8BA7FA0EC0DE = 4.0000000400000002E+127
       = 4.0000000400000002404986882959066092342679329907651524964760105627606244187779291291278299598304193209246494823007927688866299904E127
       = 4.00000004E127 + 2.404986882959066092342679329907651524964760105627606244187779291291278299598304193209246494823007927688866299904E111
expected: 5A6D8BA7FA0EC0DD = 4.0000000399999998E+127
       = 4.0000000399999997595171673438255641625023067683089292899362245463367148979247381593314216163586100995590946131001623879463469056E127
       = 4.00000004E127 - 2.404828326561744358374976932316910707100637754536632851020752618406685783836413899004409053868998376120536530944E111

Converting 4.000000000006E257 to double
got: 756AA3D4DF50DAFA = 4.0000000000059997E+257
       = 4.00000000000599973317676757824381609900916551801433948307651888113949467043929774142954821770925517811003156175732998988822328403916910228693030844790699572775311101233996009908790235236404096340821838589469428487817496629014029403402596480648189654876553216E257
       = 4.000000000006E257 - 2.6682323242175618390099083448198566051692348111886050532956070225857045178229074482188996843824267001011177671596083089771306969155209300427224688898766003990091209764763595903659178161410530571512182503370985970596597403519351810345123446784E241
expected: 756AA3D4DF50DAFB = 4.0000000000060003E+257
       = 4.00000000000600026661792220863215802539730877571496325465718466641214750213992268255252724311982089982460763148167324932261613151382833795803444077745620215682159519880636378670050871348520564045448125883981626319537625716106845256928580780459879984187572224E257
       = 4.000000000006E257 + 2.6661792220863215802539730877571496325465718466641214750213992268255252724311982089982460763148167324932261613151382833795803444077745620215682159519880636378670050871348520564045448125883981626319537625716106845256928580780459879984187572224E241

Converting 2.00000002E127 to double
got: 5A5D8BA7FA0EC0DE = 2.0000000200000001E+127
       = 2.0000000200000001202493441479533046171339664953825762482380052813803122093889645645639149799152096604623247411503963844433149952E127
       = 2.00000002E127 + 1.202493441479533046171339664953825762482380052813803122093889645645639149799152096604623247411503963844433149952E111
expected: 5A5D8BA7FA0EC0DD = 2.0000000199999999E+127
       = 2.0000000199999998797585836719127820812511533841544646449681122731683574489623690796657108081793050497795473065500811939731734528E127
       = 2.00000002E127 - 1.202414163280872179187488466158455353550318877268316425510376309203342891918206949502204526934499188060268265472E111

Converting 6.000000000003E299 to double
got: 7E2CAB7BD667034A = 6.0000000000029996E+299
       = 6.00000000000299962813296121966418518428557983607873968132187169169473023977368942702372078610412778875256541035644289308753995863880535035230901718353285600237240673551965907461216392933447093884484949794509207212837971708265048392958968914081866783603823597627377635200639502510534385590131562119168E299
       = 6.000000000003E299 - 3.7186703878033581481571442016392126031867812830830526976022631057297627921389587221124743458964355710691246004136119464964769098281646714399762759326448034092538783607066552906115515050205490792787162028291734951607041031085918133216396176402372622364799360497489465614409868437880832E283
expected: 7E2CAB7BD667034B = 6.0000000000030004E+299
       = 6.00000000000300037164141545855571658331682891102901974695197252139195976765961908499404936630631456133672265843461818798690185373529187557960163995598570989778769728671697196609758415306440791018805441509396050724797760825836908696346404257975871191458770615060281785802894775217730026778399002853376E299
       = 6.000000000003E299 + 3.7164141545855571658331682891102901974695197252139195976765961908499404936630631456133672265843461818798690185373529187557960163995598570989778769728671697196609758415306440791018805441509396050724797760825836908696346404257975871191458770615060281785802894775217730026778399002853376E283

Converting 6.000000000003E299 to double
got: 7E2CAB7BD667034A = 6.0000000000029996E+299
       = 6.00000000000299962813296121966418518428557983607873968132187169169473023977368942702372078610412778875256541035644289308753995863880535035230901718353285600237240673551965907461216392933447093884484949794509207212837971708265048392958968914081866783603823597627377635200639502510534385590131562119168E299
       = 6.000000000003E299 - 3.7186703878033581481571442016392126031867812830830526976022631057297627921389587221124743458964355710691246004136119464964769098281646714399762759326448034092538783607066552906115515050205490792787162028291734951607041031085918133216396176402372622364799360497489465614409868437880832E283
expected: 7E2CAB7BD667034B = 6.0000000000030004E+299
       = 6.00000000000300037164141545855571658331682891102901974695197252139195976765961908499404936630631456133672265843461818798690185373529187557960163995598570989778769728671697196609758415306440791018805441509396050724797760825836908696346404257975871191458770615060281785802894775217730026778399002853376E299
       = 6.000000000003E299 + 3.7164141545855571658331682891102901974695197252139195976765961908499404936630631456133672265843461818798690185373529187557960163995598570989778769728671697196609758415306440791018805441509396050724797760825836908696346404257975871191458770615060281785802894775217730026778399002853376E283

Converting 9.005E275 to double
got: 793A025D96FF0A08 = 9.0050000000000006E+275
       = 9.00500000000000061525636821678203924258117438619359277729499076316939828944692781847255126877970391300575774041669842835959600585917726674973035532704469203649183777222201086308874747447948949290097098754194136607233890947180173760785920236476906124459514359878323804458450944E275
       = 9.005E275 + 6.1525636821678203924258117438619359277729499076316939828944692781847255126877970391300575774041669842835959600585917726674973035532704469203649183777222201086308874747447948949290097098754194136607233890947180173760785920236476906124459514359878323804458450944E259
expected: 793A025D96FF0A07 = 9.0049999999999994E+275
       = 9.00499999999999938522481098541995356410669755395694861997629895601873884013989163592299604924478088290207080501520499013250550263703427122283831656008515602949408282833994944217988847718601122206778214170435701156685373380263546848237645328364139242428080431344755643491811328E275
       = 9.005E275 - 6.1477518901458004643589330244604305138002370104398126115986010836407700395075521911709792919498479500986749449736296572877716168343991484397050591717166005055782011152281398877793221785829564298843314626619736453151762354671635860757571919568655244356508188672E259

Converting 6.0000000002E299 to double
got: 7E2CAB7BD66B0E4A = 6.0000000001999996E+299
       = 6.00000000019999962816809791982367250404047866228492903283770826963043889569586524528433115751139168705701620368257942801526472370852957380563880629170098523775685197554338705155464341343439803441969726212566136078562563548371033927827687069489772030365562619911121208757696001067623628931228497870848E299
       = 6.0000000002E299 - 3.7183190208017632749595952133771507096716229173036956110430413475471566884248860831294298379631742057198473527629147042619436119370829901476224314802445661294844535658656560196558030273787433863921437436451628966072172312930510227969634437380088878791242303998932376371068771502129152E283
expected: 7E2CAB7BD66B0E4B = 6.0000000002000004E+299
       = 6.00000000020000037167655215871520390307172773723520909846780909932766842358179490325465973771357845964117345176075472291462661880501609903293142906415383913317214252674069994304006363716433500576290217927452979590522352665942894231215122413383776438220509637344025359359951273774819270119495938605056E299
       = 6.0000000002E299 + 3.7167655215871520390307172773723520909846780909932766842358179490325465973771357845964117345176075472291462661880501609903293142906415383913317214252674069994304006363716433500576290217927452979590522352665942894231215122413383776438220509637344025359359951273774819270119495938605056E283

Converting 1.001000001E285 to double
got: 7B1AED280502EFD8 = 1.0010000010000001E+285
       = 1.00100000100000006605752633205901449785586127042913394775971639830061802664510651212070636569561568176712415013782622907345136676773667968891028477795288988654429184908883015491114338639206340798228265419201847871936926326614595987704728308567160519170531337563130914042219442967937024E285
       = 1.001000001E285 + 6.605752633205901449785586127042913394775971639830061802664510651212070636569561568176712415013782622907345136676773667968891028477795288988654429184908883015491114338639206340798228265419201847871936926326614595987704728308567160519170531337563130914042219442967937024E268
expected: 7B1AED280502EFD7 = 1.0010000009999999E+285
       = 1.001000000999999933983893548142702909770915041299982318047884889270237494654929255452230726514400813162810178223529255404852618453454509968323394902281505573909547233353935927814472386640792365799403235085408215463311036213348858840040209897781170482106088683872190018037549205244870656E285
       = 1.001000001E285 - 6.6016106451857297090229084958700017681952115110729762505345070744547769273485599186837189821776470744595147381546545490031676605097718494426090452766646064072185527613359207634200596764914591784536688963786651141159959790102218829517893911316127809981962450794755129344E268

Converting 8.000000000000002E298 to double
got: 7DFE94C85C298C4E = 8.0000000000000015E+298
       = 8.0000000000000015353007633999726590881826222612906933377719841686402639557401600532464638709468630712258714227803339677645830285276132324460972716369729367059100334342085757671307722059532101774897590016030690522400457890753190315914087521006512060744582755720540170017387544463855057127476868153344E298
       = 8.000000000000002E298 - 4.646992366000273409118173777387093066622280158313597360442598399467535361290531369287741285772196660322354169714723867675539027283630270632940899665657914242328692277940467898225102409983969309477599542109246809684085912478993487939255417244279459829982612455536144942872523131846656E282
expected: 7DFE94C85C298C4F = 8.0000000000000025E+298
       = 8.000000000000002464686331198587073336971683604978543419809610205761800865597572125709374596199596536956067982878053086388785397398221388980213050102539004075179146623205216881487547485615631391668765148039154596139543153044967285383751693899326261172645113289965318884266945355225451227601029824512E298
       = 8.000000000000002E298 + 4.64686331198587073336971683604978543419809610205761800865597572125709374596199596536956067982878053086388785397398221388980213050102539004075179146623205216881487547485615631391668765148039154596139543153044967285383751693899326261172645113289965318884266945355225451227601029824512E282

Converting 2.00000002E127 to double
got: 5A5D8BA7FA0EC0DE = 2.0000000200000001E+127
       = 2.0000000200000001202493441479533046171339664953825762482380052813803122093889645645639149799152096604623247411503963844433149952E127
       = 2.00000002E127 + 1.202493441479533046171339664953825762482380052813803122093889645645639149799152096604623247411503963844433149952E111
expected: 5A5D8BA7FA0EC0DD = 2.0000000199999999E+127
       = 2.0000000199999998797585836719127820812511533841544646449681122731683574489623690796657108081793050497795473065500811939731734528E127
       = 2.00000002E127 - 1.202414163280872179187488466158455353550318877268316425510376309203342891918206949502204526934499188060268265472E111

Converting 4.000000000006E257 to double
got: 756AA3D4DF50DAFA = 4.0000000000059997E+257
       = 4.00000000000599973317676757824381609900916551801433948307651888113949467043929774142954821770925517811003156175732998988822328403916910228693030844790699572775311101233996009908790235236404096340821838589469428487817496629014029403402596480648189654876553216E257
       = 4.000000000006E257 - 2.6682323242175618390099083448198566051692348111886050532956070225857045178229074482188996843824267001011177671596083089771306969155209300427224688898766003990091209764763595903659178161410530571512182503370985970596597403519351810345123446784E241
expected: 756AA3D4DF50DAFB = 4.0000000000060003E+257
       = 4.00000000000600026661792220863215802539730877571496325465718466641214750213992268255252724311982089982460763148167324932261613151382833795803444077745620215682159519880636378670050871348520564045448125883981626319537625716106845256928580780459879984187572224E257
       = 4.000000000006E257 + 2.6661792220863215802539730877571496325465718466641214750213992268255252724311982089982460763148167324932261613151382833795803444077745620215682159519880636378670050871348520564045448125883981626319537625716106845256928580780459879984187572224E241

Converting 8.000000000000002E298 to double
got: 7DFE94C85C298C4E = 8.0000000000000015E+298
       = 8.0000000000000015353007633999726590881826222612906933377719841686402639557401600532464638709468630712258714227803339677645830285276132324460972716369729367059100334342085757671307722059532101774897590016030690522400457890753190315914087521006512060744582755720540170017387544463855057127476868153344E298
       = 8.000000000000002E298 - 4.646992366000273409118173777387093066622280158313597360442598399467535361290531369287741285772196660322354169714723867675539027283630270632940899665657914242328692277940467898225102409983969309477599542109246809684085912478993487939255417244279459829982612455536144942872523131846656E282
expected: 7DFE94C85C298C4F = 8.0000000000000025E+298
       = 8.000000000000002464686331198587073336971683604978543419809610205761800865597572125709374596199596536956067982878053086388785397398221388980213050102539004075179146623205216881487547485615631391668765148039154596139543153044967285383751693899326261172645113289965318884266945355225451227601029824512E298
       = 8.000000000000002E298 + 4.64686331198587073336971683604978543419809610205761800865597572125709374596199596536956067982878053086388785397398221388980213050102539004075179146623205216881487547485615631391668765148039154596139543153044967285383751693899326261172645113289965318884266945355225451227601029824512E282

Converting 5.5000008E293 to double
got: 7CEB8EAC748C06E2 = 5.5000007999999996E+293
       = 5.50000079999999964533204243164233684637369786202929456830823867809002810156268466508540896933564166122688154943959793806287524700675526953093660071187691539277952831255385624001868066398387752206148571800649356236581531960156097268980116950400728310573263723025092021172058312528383194842529792E293
       = 5.5000008E293 - 3.5466795756835766315362630213797070543169176132190997189843731533491459103066435833877311845056040206193712475299324473046906339928812308460722047168744614375998131933601612247793851428199350643763418468039843902731019883049599271689426736276974907978827941687471616805157470208E277
expected: 7CEB8EAC748C06E3 = 5.5000008000000004E+293
       = 5.500000800000000354396959270184828186087032017064580580605011472524794420728801053378034949905659258982463641799307958985881204702226580363239288139829542475046612959920678379267929381988044097820615163224454334994216018430943490536742500832342133491922546377827291887233424089669776707682304E293
       = 5.5000008E293 + 3.54396959270184828186087032017064580580605011472524794420728801053378034949905659258982463641799307958985881204702226580363239288139829542475046612959920678379267929381988044097820615163224454334994216018430943490536742500832342133491922546377827291887233424089669776707682304E277

Converting 5.0004E210 to double
got: 6BAE6B7E77207068 = 5.0004000000000003E+210
       = 5.00040000000000029200561338813680031036442848560100854436121565235056399577664244783805729934179571673575866334712209968930331038849797209891859785393231930613378276053822591888888722065669124277242518141140992E210
       = 5.0004E210 + 2.9200561338813680031036442848560100854436121565235056399577664244783805729934179571673575866334712209968930331038849797209891859785393231930613378276053822591888888722065669124277242518141140992E194
expected: 6BAE6B7E77207067 = 5.0003999999999997E+210
       = 5.000399999999999708013214332495812324294462955963718958027966724534892881640000156730835896631090243978918814723582928023087684968413836330764393517876255529793133836094809822633568902542777632164528573846126592E210
       = 5.0004E210 - 2.91986785667504187675705537044036281041972033275465107118359999843269164103368909756021081185276417071976912315031586163669235606482123744470206866163905190177366431097457222367835471426153873408E194

Converting 8.0000000000001E277 to double
got: 79A20D4C2FA8A070 = 8.0000000000000992E+277
       = 8.0000000000000992126878032250015677111434598032549718730380512701574865152412154885427664691627728672548811212793095018407285289419965836468138199154616764477757059067326996385605481140738653995376716977967243403424781813229336381749225507595190514010982475326012956351316099072E277
       = 8.0000000000001E277 - 7.873121967749984322888565401967450281269619487298425134847587845114572335308372271327451188787206904981592714710580034163531861800845383235522242940932673003614394518859261346004623283022032756596575218186770663618250774492404809485989017524673987043648683900928E261
expected: 79A20D4C2FA8A071 = 8.0000000000001008E+277
       = 8.000000000000100787128196481145037379590790148517876394405976783310330610354221802206197150167474345787600398593221102771404373066339617921235629537169882536732832234901738257323887630609517586204153420468832314109499206179466462655540469583362467491100601817830968095504596992E277
       = 8.0000000000001E277 + 7.87128196481145037379590790148517876394405976783310330610354221802206197150167474345787600398593221102771404373066339617921235629537169882536732832234901738257323887630609517586204153420468832314109499206179466462655540469583362467491100601817830968095504596992E261

Converting 6.000000000003E299 to double
got: 7E2CAB7BD667034A = 6.0000000000029996E+299
       = 6.00000000000299962813296121966418518428557983607873968132187169169473023977368942702372078610412778875256541035644289308753995863880535035230901718353285600237240673551965907461216392933447093884484949794509207212837971708265048392958968914081866783603823597627377635200639502510534385590131562119168E299
       = 6.000000000003E299 - 3.7186703878033581481571442016392126031867812830830526976022631057297627921389587221124743458964355710691246004136119464964769098281646714399762759326448034092538783607066552906115515050205490792787162028291734951607041031085918133216396176402372622364799360497489465614409868437880832E283
expected: 7E2CAB7BD667034B = 6.0000000000030004E+299
       = 6.00000000000300037164141545855571658331682891102901974695197252139195976765961908499404936630631456133672265843461818798690185373529187557960163995598570989778769728671697196609758415306440791018805441509396050724797760825836908696346404257975871191458770615060281785802894775217730026778399002853376E299
       = 6.000000000003E299 + 3.7164141545855571658331682891102901974695197252139195976765961908499404936630631456133672265843461818798690185373529187557960163995598570989778769728671697196609758415306440791018805441509396050724797760825836908696346404257975871191458770615060281785802894775217730026778399002853376E283

Converting 3.0000000001E299 to double
got: 7E1CAB7BD66B0E4A = 3.0000000000999998E+299
       = 3.00000000009999981408404895991183625202023933114246451641885413481521944784793262264216557875569584352850810184128971400763236185426478690281940314585049261887842598777169352577732170671719901720984863106283068039281281774185516963913843534744886015182781309955560604378848000533811814465614248935424E299
       = 3.0000000001E299 - 1.8591595104008816374797976066885753548358114586518478055215206737735783442124430415647149189815871028599236763814573521309718059685414950738112157401222830647422267829328280098279015136893716931960718718225814483036086156465255113984817218690044439395621151999466188185534385751064576E283
expected: 7E1CAB7BD66B0E4B = 3.0000000001000002E+299
       = 3.00000000010000018583827607935760195153586386861760454923390454966383421179089745162732986885678922982058672588037736145731330940250804951646571453207691956658607126337034997152003181858216750288145108963726489795261176332971447115607561206691888219110254818672012679679975636887409635059747969302528E299
       = 3.0000000001E299 + 1.8583827607935760195153586386861760454923390454966383421179089745162732986885678922982058672588037736145731330940250804951646571453207691956658607126337034997152003181858216750288145108963726489795261176332971447115607561206691888219110254818672012679679975636887409635059747969302528E283

Converting 4.00000000000005E277 to double
got: 79920D4C2FA8A070 = 4.0000000000000496E+277
       = 4.0000000000000496063439016125007838555717299016274859365190256350787432576206077442713832345813864336274405606396547509203642644709982918234069099577308382238878529533663498192802740570369326997688358488983621701712390906614668190874612753797595257005491237663006478175658049536E277
       = 4.00000000000005E277 - 3.936560983874992161444282700983725140634809743649212567423793922557286167654186135663725594393603452490796357355290017081765930900422691617761121470466336501807197259429630673002311641511016378298287609093385331809125387246202404742994508762336993521824341950464E261
expected: 79920D4C2FA8A071 = 4.0000000000000504E+277
       = 4.000000000000050393564098240572518689795395074258938197202988391655165305177110901103098575083737172893800199296610551385702186533169808960617814768584941268366416117450869128661943815304758793102076710234416157054749603089733231327770234791681233745550300908915484047752298496E277
       = 4.00000000000005E277 + 3.93564098240572518689795395074258938197202988391655165305177110901103098575083737172893800199296610551385702186533169808960617814768584941268366416117450869128661943815304758793102076710234416157054749603089733231327770234791681233745550300908915484047752298496E261

Converting 3.0000000001E299 to double
got: 7E1CAB7BD66B0E4A = 3.0000000000999998E+299
       = 3.00000000009999981408404895991183625202023933114246451641885413481521944784793262264216557875569584352850810184128971400763236185426478690281940314585049261887842598777169352577732170671719901720984863106283068039281281774185516963913843534744886015182781309955560604378848000533811814465614248935424E299
       = 3.0000000001E299 - 1.8591595104008816374797976066885753548358114586518478055215206737735783442124430415647149189815871028599236763814573521309718059685414950738112157401222830647422267829328280098279015136893716931960718718225814483036086156465255113984817218690044439395621151999466188185534385751064576E283
expected: 7E1CAB7BD66B0E4B = 3.0000000001000002E+299
       = 3.00000000010000018583827607935760195153586386861760454923390454966383421179089745162732986885678922982058672588037736145731330940250804951646571453207691956658607126337034997152003181858216750288145108963726489795261176332971447115607561206691888219110254818672012679679975636887409635059747969302528E299
       = 3.0000000001E299 + 1.8583827607935760195153586386861760454923390454966383421179089745162732986885678922982058672588037736145731330940250804951646571453207691956658607126337034997152003181858216750288145108963726489795261176332971447115607561206691888219110254818672012679679975636887409635059747969302528E283

Converting 3.0000000001E299 to double
got: 7E1CAB7BD66B0E4A = 3.0000000000999998E+299
       = 3.00000000009999981408404895991183625202023933114246451641885413481521944784793262264216557875569584352850810184128971400763236185426478690281940314585049261887842598777169352577732170671719901720984863106283068039281281774185516963913843534744886015182781309955560604378848000533811814465614248935424E299
       = 3.0000000001E299 - 1.8591595104008816374797976066885753548358114586518478055215206737735783442124430415647149189815871028599236763814573521309718059685414950738112157401222830647422267829328280098279015136893716931960718718225814483036086156465255113984817218690044439395621151999466188185534385751064576E283
expected: 7E1CAB7BD66B0E4B = 3.0000000001000002E+299
       = 3.00000000010000018583827607935760195153586386861760454923390454966383421179089745162732986885678922982058672588037736145731330940250804951646571453207691956658607126337034997152003181858216750288145108963726489795261176332971447115607561206691888219110254818672012679679975636887409635059747969302528E299
       = 3.0000000001E299 + 1.8583827607935760195153586386861760454923390454966383421179089745162732986885678922982058672588037736145731330940250804951646571453207691956658607126337034997152003181858216750288145108963726489795261176332971447115607561206691888219110254818672012679679975636887409635059747969302528E283

Converting 8.000000000000002E298 to double
got: 7DFE94C85C298C4E = 8.0000000000000015E+298
       = 8.0000000000000015353007633999726590881826222612906933377719841686402639557401600532464638709468630712258714227803339677645830285276132324460972716369729367059100334342085757671307722059532101774897590016030690522400457890753190315914087521006512060744582755720540170017387544463855057127476868153344E298
       = 8.000000000000002E298 - 4.646992366000273409118173777387093066622280158313597360442598399467535361290531369287741285772196660322354169714723867675539027283630270632940899665657914242328692277940467898225102409983969309477599542109246809684085912478993487939255417244279459829982612455536144942872523131846656E282
expected: 7DFE94C85C298C4F = 8.0000000000000025E+298
       = 8.000000000000002464686331198587073336971683604978543419809610205761800865597572125709374596199596536956067982878053086388785397398221388980213050102539004075179146623205216881487547485615631391668765148039154596139543153044967285383751693899326261172645113289965318884266945355225451227601029824512E298
       = 8.000000000000002E298 + 4.64686331198587073336971683604978543419809610205761800865597572125709374596199596536956067982878053086388785397398221388980213050102539004075179146623205216881487547485615631391668765148039154596139543153044967285383751693899326261172645113289965318884266945355225451227601029824512E282

Converting 6.000000000003E299 to double
got: 7E2CAB7BD667034A = 6.0000000000029996E+299
       = 6.00000000000299962813296121966418518428557983607873968132187169169473023977368942702372078610412778875256541035644289308753995863880535035230901718353285600237240673551965907461216392933447093884484949794509207212837971708265048392958968914081866783603823597627377635200639502510534385590131562119168E299
       = 6.000000000003E299 - 3.7186703878033581481571442016392126031867812830830526976022631057297627921389587221124743458964355710691246004136119464964769098281646714399762759326448034092538783607066552906115515050205490792787162028291734951607041031085918133216396176402372622364799360497489465614409868437880832E283
expected: 7E2CAB7BD667034B = 6.0000000000030004E+299
       = 6.00000000000300037164141545855571658331682891102901974695197252139195976765961908499404936630631456133672265843461818798690185373529187557960163995598570989778769728671697196609758415306440791018805441509396050724797760825836908696346404257975871191458770615060281785802894775217730026778399002853376E299
       = 6.000000000003E299 + 3.7164141545855571658331682891102901974695197252139195976765961908499404936630631456133672265843461818798690185373529187557960163995598570989778769728671697196609758415306440791018805441509396050724797760825836908696346404257975871191458770615060281785802894775217730026778399002853376E283

Converting 8.000000000000002E298 to double
got: 7DFE94C85C298C4E = 8.0000000000000015E+298
       = 8.0000000000000015353007633999726590881826222612906933377719841686402639557401600532464638709468630712258714227803339677645830285276132324460972716369729367059100334342085757671307722059532101774897590016030690522400457890753190315914087521006512060744582755720540170017387544463855057127476868153344E298
       = 8.000000000000002E298 - 4.646992366000273409118173777387093066622280158313597360442598399467535361290531369287741285772196660322354169714723867675539027283630270632940899665657914242328692277940467898225102409983969309477599542109246809684085912478993487939255417244279459829982612455536144942872523131846656E282
expected: 7DFE94C85C298C4F = 8.0000000000000025E+298
       = 8.000000000000002464686331198587073336971683604978543419809610205761800865597572125709374596199596536956067982878053086388785397398221388980213050102539004075179146623205216881487547485615631391668765148039154596139543153044967285383751693899326261172645113289965318884266945355225451227601029824512E298
       = 8.000000000000002E298 + 4.64686331198587073336971683604978543419809610205761800865597572125709374596199596536956067982878053086388785397398221388980213050102539004075179146623205216881487547485615631391668765148039154596139543153044967285383751693899326261172645113289965318884266945355225451227601029824512E282

Converting 3.0000000001E299 to double
got: 7E1CAB7BD66B0E4A = 3.0000000000999998E+299
       = 3.00000000009999981408404895991183625202023933114246451641885413481521944784793262264216557875569584352850810184128971400763236185426478690281940314585049261887842598777169352577732170671719901720984863106283068039281281774185516963913843534744886015182781309955560604378848000533811814465614248935424E299
       = 3.0000000001E299 - 1.8591595104008816374797976066885753548358114586518478055215206737735783442124430415647149189815871028599236763814573521309718059685414950738112157401222830647422267829328280098279015136893716931960718718225814483036086156465255113984817218690044439395621151999466188185534385751064576E283
expected: 7E1CAB7BD66B0E4B = 3.0000000001000002E+299
       = 3.00000000010000018583827607935760195153586386861760454923390454966383421179089745162732986885678922982058672588037736145731330940250804951646571453207691956658607126337034997152003181858216750288145108963726489795261176332971447115607561206691888219110254818672012679679975636887409635059747969302528E299
       = 3.0000000001E299 + 1.8583827607935760195153586386861760454923390454966383421179089745162732986885678922982058672588037736145731330940250804951646571453207691956658607126337034997152003181858216750288145108963726489795261176332971447115607561206691888219110254818672012679679975636887409635059747969302528E283

Converting 8.000000000000002E298 to double
got: 7DFE94C85C298C4E = 8.0000000000000015E+298
       = 8.0000000000000015353007633999726590881826222612906933377719841686402639557401600532464638709468630712258714227803339677645830285276132324460972716369729367059100334342085757671307722059532101774897590016030690522400457890753190315914087521006512060744582755720540170017387544463855057127476868153344E298
       = 8.000000000000002E298 - 4.646992366000273409118173777387093066622280158313597360442598399467535361290531369287741285772196660322354169714723867675539027283630270632940899665657914242328692277940467898225102409983969309477599542109246809684085912478993487939255417244279459829982612455536144942872523131846656E282
expected: 7DFE94C85C298C4F = 8.0000000000000025E+298
       = 8.000000000000002464686331198587073336971683604978543419809610205761800865597572125709374596199596536956067982878053086388785397398221388980213050102539004075179146623205216881487547485615631391668765148039154596139543153044967285383751693899326261172645113289965318884266945355225451227601029824512E298
       = 8.000000000000002E298 + 4.64686331198587073336971683604978543419809610205761800865597572125709374596199596536956067982878053086388785397398221388980213050102539004075179146623205216881487547485615631391668765148039154596139543153044967285383751693899326261172645113289965318884266945355225451227601029824512E282

Converting 8.0000000000001E277 to double
got: 79A20D4C2FA8A070 = 8.0000000000000992E+277
       = 8.0000000000000992126878032250015677111434598032549718730380512701574865152412154885427664691627728672548811212793095018407285289419965836468138199154616764477757059067326996385605481140738653995376716977967243403424781813229336381749225507595190514010982475326012956351316099072E277
       = 8.0000000000001E277 - 7.873121967749984322888565401967450281269619487298425134847587845114572335308372271327451188787206904981592714710580034163531861800845383235522242940932673003614394518859261346004623283022032756596575218186770663618250774492404809485989017524673987043648683900928E261
expected: 79A20D4C2FA8A071 = 8.0000000000001008E+277
       = 8.000000000000100787128196481145037379590790148517876394405976783310330610354221802206197150167474345787600398593221102771404373066339617921235629537169882536732832234901738257323887630609517586204153420468832314109499206179466462655540469583362467491100601817830968095504596992E277
       = 8.0000000000001E277 + 7.87128196481145037379590790148517876394405976783310330610354221802206197150167474345787600398593221102771404373066339617921235629537169882536732832234901738257323887630609517586204153420468832314109499206179466462655540469583362467491100601817830968095504596992E261

Converting 6.0000000002E299 to double
got: 7E2CAB7BD66B0E4A = 6.0000000001999996E+299
       = 6.00000000019999962816809791982367250404047866228492903283770826963043889569586524528433115751139168705701620368257942801526472370852957380563880629170098523775685197554338705155464341343439803441969726212566136078562563548371033927827687069489772030365562619911121208757696001067623628931228497870848E299
       = 6.0000000002E299 - 3.7183190208017632749595952133771507096716229173036956110430413475471566884248860831294298379631742057198473527629147042619436119370829901476224314802445661294844535658656560196558030273787433863921437436451628966072172312930510227969634437380088878791242303998932376371068771502129152E283
expected: 7E2CAB7BD66B0E4B = 6.0000000002000004E+299
       = 6.00000000020000037167655215871520390307172773723520909846780909932766842358179490325465973771357845964117345176075472291462661880501609903293142906415383913317214252674069994304006363716433500576290217927452979590522352665942894231215122413383776438220509637344025359359951273774819270119495938605056E299
       = 6.0000000002E299 + 3.7167655215871520390307172773723520909846780909932766842358179490325465973771357845964117345176075472291462661880501609903293142906415383913317214252674069994304006363716433500576290217927452979590522352665942894231215122413383776438220509637344025359359951273774819270119495938605056E283



Converting 1.142983031131382E-100 to double
got: 2B2FFFF7FFFFFF7C = 1.1429830311313821E-100
       = 1.1429830311313820634533200771254619136455809087203336911927584687454999851859773796838543966058751389466836913320594555442615698631196745157778173352953764899152707102642249333183751482945888822030048208450188746860244088901256309174300575845321936707676968580926768481731414794921875E-100
       = 1.142983031131382E-100 + 6.34533200771254619136455809087203336911927584687454999851859773796838543966058751389466836913320594555442615698631196745157778173352953764899152707102642249333183751482945888822030048208450188746860244088901256309174300575845321936707676968580926768481731414794921875E-117
expected: 2B2FFFF7FFFFFF7B = 1.1429830311313819E-100
       = 1.142983031131381936556228211343000749944353117193156350011815983690720904882961317710019502140901442326312238542845144061032016975574882185674250213114041350879952826455236011382550161509835538070063787432828532638383049851090078348290196897144542498292452137320651672780513763427734375E-100
       = 1.142983031131382E-100 - 6.3443771788656999250055646882806843649988184016309279095117038682289980497859098557673687761457154855938967983024425117814325749786885958649120047173544763988617449838490164461929936212567171467361616950148909921651709803102855457501707547862679348327219486236572265625E-117

Converting 5.648006361379507E219 to double
got: 6D8FFFF7FEFFFFFA = 5.6480063613795067E+219
       = 5.648006361379506686321202425993724107986328121951426806926318584177188657794885817040497489074405696516053437598824583415921496882951983603055656216795680768643850537605757252874430391993852205297727427934566329398329344E219
       = 5.648006361379507E219 - 3.13678797574006275892013671878048573193073681415822811342205114182959502510925594303483946562401175416584078503117048016396944343783204319231356149462394242747125569608006147794702272572065433670601670656E203
expected: 6D8FFFF7FEFFFFFB = 5.6480063613795073E+219
       = 5.648006361379507313378266190133556037311179501361296185771986759776031695672076295929504377592837135160764965135747422936252981698813889776217192693861227654112186959081269036858575452586098045330276080145125849081839616E219
       = 5.648006361379507E219 + 3.13378266190133556037311179501361296185771986759776031695672076295929504377592837135160764965135747422936252981698813889776217192693861227654112186959081269036858575452586098045330276080145125849081839616E203

Converting 4.737888884325779E226 to double
got: 6EFFFFF6FFFFFFFA = 4.7378888843257787E+226
       = 4.7378888843257787368819350427099275683918689893325229456738171664918301630195980833111907435896664290301099633226635001588868664204284173300033638286367058180940168150157602134626383968560936883946922135099868240358796869763072E226
       = 4.737888884325779E226 - 2.631180649572900724316081310106674770543261828335081698369804019166888092564103335709698900366773364998411131335795715826699966361713632941819059831849842397865373616031439063116053077864900131759641203130236928E210
expected: 6EFFFFF6FFFFFFFB = 4.7378888843257793E+226
       = 4.7378888843257792628955251975472782924908572773453895007077974488092161128476883901844061732977486403967635910815086228571837520382501886319465888470170921308754938802038452089850055097005535075610680019422585511652048605544448E226
       = 4.737888884325779E226 + 2.628955251975472782924908572773453895007077974488092161128476883901844061732977486403967635910815086228571837520382501886319465888470170921308754938802038452089850055097005535075610680019422585511652048605544448E210

Converting 8.043012710792554E-87 to double
got: 2E0FFFF3FFFFFFFC = 8.0430127107925544E-087
       = 8.0430127107925544465700797410781165927928517488431701979203553315805633229560361567860828512322403348488166520187359929475684026082446610294283613301225524297569562137284273302813179102709179177023099441450125317298880389671467128209769725799560546875E-87
       = 8.043012710792554E-87 + 4.465700797410781165927928517488431701979203553315805633229560361567860828512322403348488166520187359929475684026082446610294283613301225524297569562137284273302813179102709179177023099441450125317298880389671467128209769725799560546875E-103
expected: 2E0FFFF3FFFFFFFB = 8.0430127107925536E-087
       = 8.043012710792553553611180301800786736711954635295545626115671876269109248638971135198086049093024963405049573759337829523307189034785104607130422045811028112536414487133707044723491835204307754846185176213742089833258486208933391026221215724945068359375E-87
       = 8.043012710792554E-87 - 4.46388819698199213263288045364704454373884328123730890751361028864801913950906975036594950426240662170476692810965214895392869577954188971887463585512866292955276508164795692245153814823786257910166741513791066608973778784275054931640625E-103

Converting 4.313575011698527E68 to double
got: 4E2FFFF7FFFFFFFC = 4.3135750116985272E+068
       = 4.3135750116985272394668747818702423863431093423613557377540414242816E68
       = 4.313575011698527E68 + 2.394668747818702423863431093423613557377540414242816E52
expected: 4E2FFFF7FFFFFFFB = 4.3135750116985268E+068
       = 4.31357501169852676056201826127997414935966335788973585689806574190592E68
       = 4.313575011698527E68 - 2.3943798173872002585064033664211026414310193425809408E52

Converting 7.111162215780465E103 to double
got: 557FBFF7FFFFFFFC = 7.1111622157804654E+103
       = 7.1111622157804653980021115618924618183227693994487494652326449704020674476150688931644648670090363928576E103
       = 7.111162215780465E103 + 3.980021115618924618183227693994487494652326449704020674476150688931644648670090363928576E87
expected: 557FBFF7FFFFFFFB = 7.1111622157804646E+103
       = 7.111162215780464602284933306233834369711172364535405304502803694645719542872705864109269646955635539968E103
       = 7.111162215780465E103 - 3.97715066693766165630288827635464594695497196305354280457127294135890730353044364460032E87

Converting 5.688929772624372E104 to double
got: 55AFBFF7FFFFFFFC = 5.6889297726243723E+104
       = 5.68892977262437231840168924951396945465821551955899957218611597632165395809205511453157189360722911428608E104
       = 5.688929772624372E104 + 3.1840168924951396945465821551955899957218611597632165395809205511453157189360722911428608E88
expected: 55AFBFF7FFFFFFFB = 5.6889297726243717E+104
       = 5.6889297726243716818279466449870674957689378916283242436022429557165756342981646912874157175645084319744E104
       = 5.688929772624372E104 - 3.181720533550129325042310621083716757563977570442834243657018353087125842824354915680256E88

Converting 4.596522290942083E-187 to double
got: 193FFFEFFFFFFFFA = 4.5965222909420833E-187
       = 4.5965222909420832552525148347647546695721388801025300127822545531477334680414768655312791292119200150616670203144053220556117929649395322060408386452677811999117295940986940204324778938871530581567775393435037306827799140737301920284150747450965101984941675951341118575451622884925157590074975125985253413147228795819594246210762347944940028608871586732351531179392736267624557291290124250152287071834393326659885022845055867062180112600513711730576549285842702374793589115142822265625E-187
       = 4.596522290942083E-187 + 2.552525148347647546695721388801025300127822545531477334680414768655312791292119200150616670203144053220556117929649395322060408386452677811999117295940986940204324778938871530581567775393435037306827799140737301920284150747450965101984941675951341118575451622884925157590074975125985253413147228795819594246210762347944940028608871586732351531179392736267624557291290124250152287071834393326659885022845055867062180112600513711730576549285842702374793589115142822265625E-203
expected: 193FFFEFFFFFFFF9 = 4.5965222909420827E-187
       = 4.59652229094208274493213333856929685142415474673956607024872748900204566986258046663894369487599852585946107511119947769320707180003675131790226065919426341359281307883510944281969303886452713875367154361688718538289757797208771977739478347118305664533733916519191089425520720075241264377858446295362877891258281978870188148250427046744908793973206344222242449288848105534298911847041240389438524497294721722785195018280951840385837431750891781713497241668164861039258539676666259765625E-187
       = 4.596522290942083E-187 - 2.5506786666143070314857584525326043392975127251099795433013741953336105630512400147414053892488880052230679292819996324868209773934080573658640718692116489055718030696113547286124632845638311281461710242202791228022260521652881694335466266083480808910574479279924758735622141553704637122108741718021129811851749572953255091206026793655777757550711151894465701088152958759610561475502705278277214804981719048159614162568249108218286502758331835138960741460323333740234375E-203

Converting 6.469030023958787E-173 to double
got: 1C2FFFEFFFFFDFFA = 6.4690300239587866E-173
       = 6.4690300239587866408490416863208443403770012437543386961368203810893856521620253550033818958025893167375193944632831455347047532813880662558431207339488916511467806503139833702739983562982274526493946936783858108412427543989865830188449518007828428864654753720315738142941647858467450466861032603973829214906224594076240223039933257031636185350859012901134313064981014019614580381616840972198396594257607006045636410807020411084522493183612823486328125E-173
       = 6.469030023958787E-173 - 3.591509583136791556596229987562456613038631796189106143478379746449966181041974106832624806055367168544652952467186119337441568792660511083488532193496860166297260016437017725473506053063216141891587572456010134169811550481992171571135345246279684261857058352141532549533138967396026170785093775405923759776960066742968363814649140987098865686935018985980385419618383159027801603405742392993954363589192979588915477506816387176513671875E-189
expected: 1C2FFFEFFFFFDFFB = 6.4690300239587874E-173
       = 6.46903002395878735906112916939435240653947859175681313260022244669370636612910343244002360687701235441003839148134588733119003689832202534077919862467479680320054070248436855891743193604146917290902689293808175658415125926732123242927212791007721728899633664616316262548527357149929375383417453345239542465596489505462891354992203025272772583085891819329051931610443395988830151717470034123377447560130723371355464246246214088387205265462398529052734375E-173
       = 6.469030023958787E-173 + 3.5906112916939435240653947859175681313260022244669370636612910343244002360687701235441003839148134588733119003689832202534077919862467479680320054070248436855891743193604146917290902689293808175658415125926732123242927212791007721728899633664616316262548527357149929375383417453345239542465596489505462891354992203025272772583085891819329051931610443395988830151717470034123377447560130723371355464246246214088387205265462398529052734375E-189
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Relationships

related to 0025241 closedJonas Maebe [Feature] Reimplementing of floating-point <-> ASCII conversions 
has duplicate 0036867 resolvedFlorian trystrtofloat donne une valeur incorrecte 
related to 0034269 resolvedJonas Maebe The result of FPU calculations depends on the maximally supported FPU precision 

Activities

Benito van der Zander

2016-01-28 19:56

reporter  

ftest.pas (4,136 bytes)   
program ftest;
{$mode objfpc}

//{$define hasbigdecimal}

uses sysutils{$ifdef hasbigdecimal}, bigdecimalmath{$endif};
  function rawdouble(r: int64): double;
  begin
    result := pdouble(@r)^;
  end;
  procedure writedouble(d: double; decimal: string);
  {$ifdef hasbigdecimal}
  var
    got: BigDecimal;
    expected: BigDecimal;
  {$endif}
  begin
    writeln(inttohex(pint64(@d)^, 8), ' = ', d);

    {$ifdef hasbigdecimal}
    got := FloatToBigDecimal(d, bdffExact);
    expected := StrToBigDecimal(decimal);
    writeln('       = ', BigDecimalToStr(got, bdfExponent));
    write  ('       = ', decimal);
    if got >= expected then writeln(' + ', BigDecimalToStr(got - expected, bdfExponent ))
    else writeln(' - ', BigDecimalToStr(expected - got, bdfExponent ));
    {$endif}

  end;
  procedure test(decimal: string; doubleHex: int64);
  var d: double; code: integer;
    expected: Double;
  begin
    expected := rawdouble(doubleHex);
    val(decimal, d, code);
    if d = expected then begin
      writeln('OKAYOKAYOKAYOKAYOKAYOKAYOKAY');
      exit;
    end;
    writeln('Converting ', decimal, ' to double ');
    write('got: '); writedouble(d, decimal);
    write('expected: ');writedouble(expected, decimal);
    writeln;
  end;
var d:double;
begin

  test('1.584563250377521E29', $4600000000040001);
  test('3.169126500755042E29', $4610000000040001);
  test('2.854495725694287E45', $4960000020000001);
  test('2.208559357534439E71', $4EC0000040000001);
  test('4.417118715068878E71', $4ED0000040000001);
  test('4.383627059105937E-193', $1800000200000001);
  test('1.957195664071263E-294', $2F4000000000001);
  test('3.914391328142526E-294', $304000000000001);
  test('1.250000000004549E-1', $3FC0000000004005);
  test('2.500000000009098E-1', $3FD0000000004005);
  test('5.68434222621747E-14', $3D30000010100001);
  test('1.136868445243494E-13', $3D40000010100001);
  test('2.273736890486988E-13', $3D50000010100001);
  test('3.835229384285829E-93', $2CC0000008040001);
  test('3.009265630590755E-36', $3890000008400001);


  test('6.000600000008E265', $771DC68491C306E1);
  test('8.007E248', $739CA1254F8DF33B);
  test('6.0000000002E299', $7E2CAB7BD66B0E4B);
  test('8.0000000002E285', $7B4AE64521FA3CC7);
  test('5.000000000400007E160', $614C73892ED5C299);
  test('9.005E275', $793A025D96FF0A07);
  test('4.000000000006E257', $756AA3D4DF50DAFB);
  test('4.00000004E127', $5A6D8BA7FA0EC0DD);
  test('4.000000000006E257', $756AA3D4DF50DAFB);
  test('2.00000002E127', $5A5D8BA7FA0EC0DD);
  test('6.000000000003E299', $7E2CAB7BD667034B);
  test('6.000000000003E299', $7E2CAB7BD667034B);
  test('9.005E275', $793A025D96FF0A07);
  test('6.0000000002E299', $7E2CAB7BD66B0E4B);
  test('1.001000001E285', $7B1AED280502EFD7);
  test('8.000000000000002E298', $7DFE94C85C298C4F);
  test('2.00000002E127', $5A5D8BA7FA0EC0DD);
  test('4.000000000006E257', $756AA3D4DF50DAFB);
  test('8.000000000000002E298', $7DFE94C85C298C4F);
  test('5.5000008E293', $7CEB8EAC748C06E3);
  test('5.0004E210', $6BAE6B7E77207067);
  test('8.0000000000001E277', $79A20D4C2FA8A071);
  test('6.000000000003E299', $7E2CAB7BD667034B);
  test('3.0000000001E299', $7E1CAB7BD66B0E4B);
  test('4.00000000000005E277', $79920D4C2FA8A071);
  test('3.0000000001E299', $7E1CAB7BD66B0E4B);
  test('3.0000000001E299', $7E1CAB7BD66B0E4B);
  test('8.000000000000002E298', $7DFE94C85C298C4F);
  test('6.000000000003E299', $7E2CAB7BD667034B);
  test('8.000000000000002E298', $7DFE94C85C298C4F);
  test('3.0000000001E299', $7E1CAB7BD66B0E4B);
  test('8.000000000000002E298', $7DFE94C85C298C4F);
  test('8.0000000000001E277', $79A20D4C2FA8A071);
  test('6.0000000002E299', $7E2CAB7BD66B0E4B);

  test('1.142983031131382E-100', $2B2FFFF7FFFFFF7B);
  test('5.648006361379507E219', $6D8FFFF7FEFFFFFB);
  test('4.737888884325779E226', $6EFFFFF6FFFFFFFB);
  test('8.043012710792554E-87', $2E0FFFF3FFFFFFFB);
  test('4.313575011698527E68', $4E2FFFF7FFFFFFFB);
  test('7.111162215780465E103', $557FBFF7FFFFFFFB);
  test('5.688929772624372E104', $55AFBFF7FFFFFFFB);
  test('4.596522290942083E-187', $193FFFEFFFFFFFF9);
  test('6.469030023958787E-173', $1C2FFFEFFFFFDFFB);

end.
ftest.pas (4,136 bytes)   

Jonas Maebe

2016-01-28 22:44

manager   ~0089487

FPC 3.0 uses the Grisu1 algorithm for both string-to-float and float-to-string conversions. A formal description of its behaviour can be found in http://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf

I'm pretty sure the behaviour you are seeing is as designed, and falls within the error margins and behaviour specified in the paper. Its main goal is to be fast, and to be reversible (converting the string conversion back to floating point results in the same bit pattern as the original), along with an error of maximally 0.4ulp (or 0.5 ulp in case it falls right in the middle of two valid representations).

Max Nazhalov

2016-01-29 01:12

reporter   ~0089491

Last edited: 2016-01-29 01:25

View 2 revisions

Indeed, correct string->float conversion is much more tricky than the float->string.
Strightforward approach not always gives the best approximation, but considered acceptable by IEEE.

More info can be found in
[ACM SIGPLAN'90 Conference on Programming Language Design and Implementation]
William D Clinger, How to Read Floating Point Numbers Accurately
http://www.cesura17.net/~will/professional/research/papers/howtoread.pdf

Jonas Maebe

2016-01-29 10:53

manager   ~0089494

See comments above.

Benito van der Zander

2016-01-29 14:57

reporter   ~0089500

>falls within the error margins and behaviour specified in the paper

But that paper is in the other direction

>Strightforward approach not always gives the best approximation, but considered acceptable by IEEE.

Hard to say what the IEEE considers acceptable, when they do not open source their standards. But googling revealed

>IEEE 754 requires correct rounding for double precision for numbers in the range [10^−27, , 10^44] only,

1.250000000004549E-1, 1.136868445243494E-13 or 1.584563250377521E29 are in that range and not correctly rounded.

Max Nazhalov

2016-01-29 16:14

reporter   ~0089505

Last edited: 2016-01-29 16:43

View 4 revisions

You haven't tried to fill "Platform"/"OS" fields. Do you experiment with "double" on an "extended" hardware?..
If so -- beware, in any case all values are passed as float80, and printed/evaluated as float80, and generated digits are just rounded to 17 from 21 during float->str by means of software ("TiesToAway", disregarding of current FPU rounding mode), and the evaluated value is rounded-down from 80 to 64 bits during str->float by means of FPU (just an assignment -- it regards current FPU rounding mode, but first it evaluated as float80 with forced "TiesToEven").

Benito van der Zander

2016-01-29 17:52

reporter   ~0089508

> You haven't tried to fill "Platform"/"OS" fields. Do you experiment with "double" on an "extended" hardware?..

normal amd64

>and the evaluated value is rounded-down from 80 to 64 bits during str->float by means of FPU (just an assignment -- it regards current FPU rounding mode, but first it evaluated as float80 with forced "TiesToEven").


So it converts string -> extended -> double

The numbers do not tie, when written as double, but they do, as extended


Converting 1.421085474167199E-14 to double
extended = 0.000000000000014210854741671990000676538852540596019122915404098161928914123564027249813079833984375
        delta to got double 0.000000000000000000000000000001577721810442023610823457130565572459346412870218046009540557861328125
        delta to expected double -0.000000000000000000000000000001577721810442023610823457130565572459346412870218046009540557861328125

got double: 3D10000000800042 = 1.4210854741671992E-014
       = 1.42108547416719915783983492945642068425800459696706212753269937820732593536376953125E-14
       = 1.421085474167199E-14 + 1.5783983492945642068425800459696706212753269937820732593536376953125E-30
       delta 0.5002144037 ULP
expected: 3D10000000800041 = 1.4210854741671988E-014
       = 1.421085474167198842295472841051698519566578483852570258250125334598124027252197265625E-14
       = 1.421085474167199E-14 - 1.57704527158948301480433421516147429741749874665401875972747802734375E-30
       delta 0.4997855963 ULP
ULP (double): 3.15544362088404722164691426113114491869282574043609201908111572265625E-30

Probably it needs to round the extended towards the input, and not to even

Max Nazhalov

2016-01-30 07:13

reporter   ~0089517

Last edited: 2016-01-30 07:31

View 3 revisions

Some observations:

1. For all provided examples rounding mode in effect during f80->double seems to be rmNearest (tiesToEven).
Only with this rounding mode ALL examples are 1ulp away from what you call "expected".
In all other rounding modes about a half of examples gives "expected" result.

2. For all examples conversion of provided ascii representation to extended gives a bitpattern which mantissa ends with
[bin] ..100 0000 0000
i.e. rounding it to double triggers tiesToEven behavior.

3. For all examples rounding f80 to double gives "expected" result if there would be a [nonexistent] tiesToOdd rounding mode.

[update]
4. Evaluating directly to double (e.g. on machine without f80, or using crafted softfpu) whith the same algorythm gives some hits to "expected", but most samples are still +/-1ulp from it.

Benito van der Zander

2016-01-30 10:11

reporter   ~0089520

Because those are the numbers that failed with the default rounding (tiesToEven).

If there was a tiesToOdd active, it would probably have listed other numbers

Max Nazhalov

2016-01-30 15:21

reporter   ~0089529

Last edited: 2016-01-31 16:06

View 5 revisions

As I already mentioned, current INPUT (str->float) routine [strightforward approach, even with the help of some more precise helpers] is not "ideal" in the sence of the article linked above. The "ideal" INPUT routine (approximation falls within 0.5 ulp) unavoidably should use bignums in some border cases [at least for now, while nobody had presented a better approach].
IEEE requirement is to stay within 0.97 ulp (again, see page 1 of the Clinger's article linked above).

Benito van der Zander

2016-01-31 16:33

reporter   ~0089615

> IEEE requirement is to stay within 0.97 ulp

Only for numbers with an |exponent| > 27

Other numbers should be rounded correctly

Max Nazhalov

2016-01-31 17:01

reporter   ~0089618

Last edited: 2016-01-31 17:53

View 5 revisions

Personally I'm against of introducing bignums into RTL, with their unpredictable memory usage etc..
So I can live with 0.97 for now.
And You can use specialized conversion libraries for Your own specialized purpose.
Thanks for report, samples, and discussion. :-)

[edit]
BTW, that is why I stayed with Grisu1 for float->ascii, and not Grisu2 (its output not always can be evaluated back exactly with "non-ideal" INPUT routine), and not Grisu3 (it requires fallback to bignums-alg again, i.e. Dragon*).

Jonas Maebe

2016-02-02 00:22

manager   ~0089672

Maybe it will be fixed one day, but I doubt it will change any time soon.

Max Nazhalov

2016-02-02 15:13

reporter   ~0089693

Last edited: 2016-02-02 15:16

View 2 revisions

Agreed. But the 0th step could be done even now. ;)
Just make this stuff "plugable" -- some kind of TFloatConverter, like TMemoryManager/TThreadManager et al.
There are just 2 compilerprocs (str_real, val_real) and 1 enum (TReal_Type).

Marco van de Voort

2018-10-21 21:43

manager   ~0111506

Please no. The additional overhead is worse then either option for many of us.

Florian

2020-04-13 13:59

administrator   ~0122123

The additional overhead of a plugin approach is neglible considering the immense effort to do the conversion. In particular as any modern processor would perfectly predict such a plugin call. So if somebody wants to provide a plugin, I think we should integrate it as there is not the one and only solution.

Max Nazhalov

2020-05-02 20:51

reporter   ~0122606

Last edited: 2020-05-02 21:15

View 2 revisions

Just a concept draft (didn't test it though yet, it just compiles for now, win32-i386) -- no compiler changes, rtl-only. Suggestions are welcome.
draft20200503.diff (10,332 bytes)   
Index: rtl/inc/flt_conv.inc
===================================================================
--- rtl/inc/flt_conv.inc	(revision 45221)
+++ rtl/inc/flt_conv.inc	(working copy)
@@ -210,16 +210,6 @@
  *-------------------------------------------------------*)
 
 type
-    TReal_Type = (
-        RT_S32REAL,  // single
-        RT_S64REAL,  // double
-        RT_S80REAL,  // extended [80-bit]
-        RT_SC80REAL, // extended ["C-extended"; functionally the same as RT_S80REAL, but may be different in alignment and padding]
-        RT_C64BIT,   // comp [legacy; just an int64 passed via float]
-        RT_CURRENCY, // currency [seems never passed to str_real since it has its own dedicated converters after r5866]
-        RT_S128REAL  // float128
-    );
-
     // JVM target: explicitly define this record type to avoid "ie2011032601"
     TFloatFormatProfile = record
         nDig_mantissa, nDig_exp10: integer;
@@ -287,7 +277,7 @@
     {$undef  VALREAL_128}
 
  // Name remapping
-    {$define val_real:=ascii_to_float32}
+    {$define asciireal_eval_default:=ascii_to_float32}
     {$define ValReal:=float32rec}
     {$define TDIY_FP:=TDIY_FP32}
     {$define TDIY_FP_Power_of_10:=TDIY_FP32_Power_of_10}
@@ -305,7 +295,7 @@
     {$undef  VALREAL_128}
 
  // Name remapping
-    {$define val_real:=ascii_to_float64}
+    {$define asciireal_eval_default:=ascii_to_float64}
     {$define ValReal:=float64}
     {$define TDIY_FP:=TDIY_FP64}
     {$define TDIY_FP_Power_of_10:=TDIY_FP64_Power_of_10}
@@ -323,7 +313,7 @@
     {$undef  VALREAL_128}
 
  // Name remapping
-    {$define val_real:=ascii_to_floatx80}
+    {$define asciireal_eval_default:=ascii_to_floatx80}
     {$define ValReal:=floatx80}
     {$define TDIY_FP:=TDIY_FP96}
     {$define TDIY_FP_Power_of_10:=TDIY_FP96_Power_of_10}
@@ -341,7 +331,7 @@
     {$define VALREAL_128}
 
  // Name remapping
-    {$define val_real:=ascii_to_float128}
+    {$define asciireal_eval_default:=ascii_to_float128}
     {$define ValReal:=float128}
     {$define TDIY_FP:=TDIY_FP128}
     {$define TDIY_FP_Power_of_10:=TDIY_FP128_Power_of_10}
@@ -358,7 +348,7 @@
     {$undef VALREAL_80}
     {$undef VALREAL_128}
     {$undef VALREAL_PACK}
-    {$undef val_real}
+    {$undef asciireal_eval_default}
     {$undef ValReal}
     {$undef ValSInt}
     {$undef TDIY_FP}
Index: rtl/inc/flt_core.inc
===================================================================
--- rtl/inc/flt_core.inc	(revision 45221)
+++ rtl/inc/flt_core.inc	(working copy)
@@ -684,7 +684,7 @@
  *                                                                          *
  *==========================================================================*)
 
-procedure str_real( min_width, frac_digits: integer; const v: ValReal; real_type: TReal_Type; out str: shortstring );
+procedure asciireal_print_default( min_width, frac_digits: integer; const v: ValReal; real_type: TReal_Type; out str: shortstring );
 
 {$undef VALREAL_PACK}
 {$i flt_pack.inc}
@@ -1903,23 +1903,6 @@
 
 end;
 
-(****************************************************************************)
-
-{$ifndef fpc_softfpu_implementation}
-procedure str_real_iso( len, f: longint; d: ValReal; real_type: treal_type; out s: string );
-var
-    i: integer;
-begin
-    str_real( len, f, d, real_type, s );
-    for i := length( s ) downto 1 do
-        if ( s[i] ='E' ) then
-        begin
-            s[i] := 'e';
-            break; // only one "E" expected
-        end;
-end;
-{$endif not fpc_softfpu_implementation}
-
 (*==========================================================================*
  *                                                                          *
  *                              ASCII -> Float                              *
@@ -1926,7 +1909,7 @@
  *                                                                          *
  *==========================================================================*)
 
-function val_real( const src: shortstring; out err_pos: ValSInt ): ValReal;
+function asciireal_eval_default( const src: shortstring; out err_pos: ValSInt ): ValReal;
 
 {$define VALREAL_PACK}
 {$i flt_pack.inc}
@@ -2296,14 +2279,14 @@
 
     // Pre-initialize result
 {$ifdef GRISU1_A2F_ERROR_RET0}
-    pack_float( val_real, false, 0, {$ifdef VALREAL_128} 0, {$endif} 0 );
+    pack_float( asciireal_eval_default, false, 0, {$ifdef VALREAL_128} 0, {$endif} 0 );
 {$else}
   {-ifdef GRISU1_A2F_NO_SNAN}
     // "real indefinite"
-    pack_float( val_real, true, C_EXP2_SPECIAL, {$ifdef VALREAL_128} C_FLT_MANT_QNANh, {$endif} C_FLT_MANT_QNAN );
+    pack_float( asciireal_eval_default, true, C_EXP2_SPECIAL, {$ifdef VALREAL_128} C_FLT_MANT_QNANh, {$endif} C_FLT_MANT_QNAN );
 (*{-else}
     // SNaN is preferable for catching uninitialized variables access, but may cause troubles with implicit float type conversions
-    pack_float( val_real, false, C_EXP2_SPECIAL, {$ifdef VALREAL_128} C_FLT_MANT_SNANh, {$endif} C_FLT_MANT_SNAN );
+    pack_float( asciireal_eval_default, false, C_EXP2_SPECIAL, {$ifdef VALREAL_128} C_FLT_MANT_SNANh, {$endif} C_FLT_MANT_SNAN );
   {-endif}*)
 {$endif}
 
@@ -2376,7 +2359,7 @@
         end;
         if special then
         begin
-            pack_float( val_real, minus, C_EXP2_SPECIAL, {$ifdef VALREAL_128} mantissa_h, {$endif} mantissa );
+            pack_float( asciireal_eval_default, minus, C_EXP2_SPECIAL, {$ifdef VALREAL_128} mantissa_h, {$endif} mantissa );
             src_pos := 0;
         end;
         err_pos := src_pos;
@@ -2548,7 +2531,7 @@
     if ( mantissa {$if defined(VALREAL_80) or defined(VALREAL_128)} or mantissa_h {$endif} = 0 )
     or ( exp10 <= - C_EXP10_OVER ) then
     begin
-        pack_float( val_real, minus, 0, {$ifdef VALREAL_128} 0, {$endif} 0 ); // +0|-0
+        pack_float( asciireal_eval_default, minus, 0, {$ifdef VALREAL_128} 0, {$endif} 0 ); // +0|-0
         err_pos := 0;
         exit;
     end;
@@ -2732,18 +2715,18 @@
     if ( overflow < 0 ) then
     begin
         // underflow [+0|-0]
-        pack_float( val_real, minus, 0, {$ifdef VALREAL_128} 0, {$endif} 0 );
+        pack_float( asciireal_eval_default, minus, 0, {$ifdef VALREAL_128} 0, {$endif} 0 );
     end
     else
     if ( overflow > 0 ) then
     begin
         // overflow [+Inf|-Inf]
-        pack_float( val_real, minus, C_EXP2_SPECIAL, {$ifdef VALREAL_128} C_FLT_MANT_INFh, {$endif} C_FLT_MANT_INF );
+        pack_float( asciireal_eval_default, minus, C_EXP2_SPECIAL, {$ifdef VALREAL_128} C_FLT_MANT_INFh, {$endif} C_FLT_MANT_INF );
     end
     else
     begin
         // no error
-        pack_float( val_real, minus, D.e, {$ifdef VALREAL_128} D.fh, {$endif} D.f );
+        pack_float( asciireal_eval_default, minus, D.e, {$ifdef VALREAL_128} D.fh, {$endif} D.f );
     end;
     err_pos := 0;
 
Index: rtl/inc/sstrings.inc
===================================================================
--- rtl/inc/sstrings.inc	(revision 45221)
+++ rtl/inc/sstrings.inc	(working copy)
@@ -490,20 +490,42 @@
 { compilerproc name will fail (JM)                                       }
 
 {$ifndef FPUNONE}
-{$ifdef FLOAT_ASCII_FALLBACK}
-{$I real2str.inc}
-{$else not FLOAT_ASCII_FALLBACK}
-{$I flt_conv.inc}
-{$endif FLOAT_ASCII_FALLBACK}
-{$endif}
 
-{$ifndef FPUNONE}
-procedure fpc_shortstr_float(d : ValReal;len,fr,rt : SizeInt;out s : shortstring);[public,alias:'FPC_SHORTSTR_FLOAT']; compilerproc;
+type
+  TReal_Type = TFPCRealType;
+
+procedure fpc_shortstr_float( d: ValReal; len, fr, rt: SizeInt; out s: shortstring ); [public,alias:'FPC_SHORTSTR_FLOAT']; compilerproc;
 begin
-  str_real(len,fr,d,treal_type(rt),s);
+  asciirealconverter.print(len,fr,d,treal_type(rt),s);
 end;
-{$endif}
 
+procedure str_real( min_width, frac_digits: integer; const v: ValReal; real_type: TReal_Type; out str: shortstring ); {$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  asciirealconverter.print(min_width,frac_digits,v,real_type,str);
+end;
+
+procedure str_real_iso( len, f: longint; d: ValReal; real_type: treal_type; out s: string );
+var
+  i: integer;
+begin
+  asciirealconverter.print(len,f,d,real_type,s);
+  for i := length(s) downto 1 do
+    if s[i]='E' then
+      begin
+        s[i] := 'e';
+        break; // only one "E" expected
+      end;
+end;
+
+function val_real( const src: shortstring; out err_pos: ValSInt ): ValReal; {$ifdef SYSTEMINLINE}inline;{$endif}
+begin
+  val_real := asciirealconverter.eval(src,err_pos);
+end;
+
+{$I flt_conv.inc}
+
+{$endif FPUNONE}
+
 {$ifndef FPC_STR_ENUM_INTERN}
 function fpc_shortstr_enum_intern(ordinal,len:sizeint;typinfo,ord2strindex:pointer;out s:shortstring): longint;
 
Index: rtl/inc/systemh.inc
===================================================================
--- rtl/inc/systemh.inc	(revision 45221)
+++ rtl/inc/systemh.inc	(working copy)
@@ -1762,3 +1762,39 @@
 {$ifdef fpdocsystem}
 {$i system.fpd}
 {$endif}
+
+{*****************************************************************************
+                           Floating-point <-> ASCII
+*****************************************************************************}
+
+{$ifndef FPUNONE}
+
+type
+  TFPCRealType = (
+    RT_S32REAL,  // single
+    RT_S64REAL,  // double
+    RT_S80REAL,  // extended [80-bit]
+    RT_SC80REAL, // extended ["C-extended"; functionally the same as RT_S80REAL, but may be different in alignment and padding]
+    RT_C64BIT,   // comp [legacy; just an int64 passed via float]
+    RT_CURRENCY, // currency [seems never passed to str_real since it has its own dedicated converters after r5866]
+    RT_S128REAL  // float128
+  );
+
+  TFPCASCIIRealPrint = procedure ( min_width, frac_digits: integer; const v: ValReal; real_type: TFPCRealType; out str: shortstring );
+  TFPCASCIIRealEval = function ( const src: shortstring; out err_pos: ValSInt ): ValReal;
+
+  TFPCASCIIRealConverter = record
+    print: TFPCASCIIRealPrint;
+    eval: TFPCASCIIRealEval;
+  end;
+
+procedure asciireal_print_default( min_width, frac_digits: integer; const v: ValReal; real_type: TFPCRealType; out str: shortstring );
+function asciireal_eval_default( const src: shortstring; out err_pos: ValSInt ): ValReal;
+
+var
+  asciirealconverter: TFPCASCIIRealConverter =(
+    print: @asciireal_print_default;
+    eval: @asciireal_eval_default;
+  );
+
+{$endif FPUNONE}
draft20200503.diff (10,332 bytes)   

Issue History

Date Modified Username Field Change
2016-01-28 19:56 Benito van der Zander New Issue
2016-01-28 19:56 Benito van der Zander File Added: ftest.pas
2016-01-28 22:44 Jonas Maebe Note Added: 0089487
2016-01-28 22:45 Jonas Maebe Relationship added related to 0025241
2016-01-29 01:12 Max Nazhalov Note Added: 0089491
2016-01-29 01:25 Max Nazhalov Note Edited: 0089491 View Revisions
2016-01-29 10:53 Jonas Maebe Note Added: 0089494
2016-01-29 10:53 Jonas Maebe Status new => resolved
2016-01-29 10:53 Jonas Maebe Resolution open => no change required
2016-01-29 10:53 Jonas Maebe Assigned To => Jonas Maebe
2016-01-29 14:57 Benito van der Zander Note Added: 0089500
2016-01-29 14:57 Benito van der Zander Status resolved => feedback
2016-01-29 14:57 Benito van der Zander Resolution no change required => reopened
2016-01-29 16:14 Max Nazhalov Note Added: 0089505
2016-01-29 16:17 Max Nazhalov Note Edited: 0089505 View Revisions
2016-01-29 16:25 Max Nazhalov Note Edited: 0089505 View Revisions
2016-01-29 16:43 Max Nazhalov Note Edited: 0089505 View Revisions
2016-01-29 17:52 Benito van der Zander Note Added: 0089508
2016-01-29 17:52 Benito van der Zander Status feedback => assigned
2016-01-30 07:13 Max Nazhalov Note Added: 0089517
2016-01-30 07:31 Max Nazhalov Note Edited: 0089517 View Revisions
2016-01-30 07:31 Max Nazhalov Note Edited: 0089517 View Revisions
2016-01-30 10:11 Benito van der Zander Note Added: 0089520
2016-01-30 15:21 Max Nazhalov Note Added: 0089529
2016-01-30 15:24 Max Nazhalov Note Edited: 0089529 View Revisions
2016-01-31 15:25 Max Nazhalov Note Edited: 0089529 View Revisions
2016-01-31 16:04 Max Nazhalov Note Edited: 0089529 View Revisions
2016-01-31 16:06 Max Nazhalov Note Edited: 0089529 View Revisions
2016-01-31 16:33 Benito van der Zander Note Added: 0089615
2016-01-31 17:01 Max Nazhalov Note Added: 0089618
2016-01-31 17:02 Max Nazhalov Note Edited: 0089618 View Revisions
2016-01-31 17:11 Max Nazhalov Note Edited: 0089618 View Revisions
2016-01-31 17:37 Max Nazhalov Note Edited: 0089618 View Revisions
2016-01-31 17:53 Max Nazhalov Note Edited: 0089618 View Revisions
2016-02-02 00:22 Jonas Maebe Note Added: 0089672
2016-02-02 00:22 Jonas Maebe Assigned To Jonas Maebe =>
2016-02-02 00:22 Jonas Maebe Status assigned => new
2016-02-02 15:13 Max Nazhalov Note Added: 0089693
2016-02-02 15:16 Max Nazhalov Note Edited: 0089693 View Revisions
2018-10-21 18:54 Jonas Maebe Relationship added related to 0034269
2018-10-21 21:43 Marco van de Voort Note Added: 0111506
2020-04-13 13:55 Florian Relationship added has duplicate 0036867
2020-04-13 13:59 Florian Note Added: 0122123
2020-05-02 20:51 Max Nazhalov Note Added: 0122606
2020-05-02 20:51 Max Nazhalov File Added: draft20200503.diff
2020-05-02 21:15 Max Nazhalov Note Edited: 0122606 View Revisions