# Pastebin 4Ff0SKWm 8:57 AM <+devsnek> what's the best way to implement exponentiation 8:57 AM <+devsnek> like what algorithm 8:58 AM <+devsnek> V8 is using fdlibm and it really really sucks 9:56 AM <+rkirsling> that's what JSC has too but I'm not familiar with what that is versus other options 9:59 AM <+devsnek> jsc calls std::pow iirc 9:59 AM <+devsnek> other fdlibm stuff works well, like sin and cos and exp 10:02 AM <+rkirsling> oh oops the fdlibm is copy-pasted in for iOS and ARM Thumb-2 while std::pow is default, you're right 10:03 AM ⇐ Ms2ger quit (~Ms2ger@ptr-g1wjcuh999hln6zoxci.18120a2.ip6.access.telenet.be) Quit: Ex-Chat 10:03 AM <+rkirsling> (there's also some JIT fast-pathing but yeah) 10:33 AM <+devsnek> sm uses std::pow too i think 10:34 AM <+devsnek> but V8 doesn't want to use it cuz it could be different across platforms 2:45 PM <+devsnek> rkirsling: do you know if there are any bugs for jsc about inaccurate exponentiation results? 2:46 PM <+rkirsling> I don't believe so 2:47 PM <+rkirsling> I see https://bugs.webkit.org/show_bug.cgi?id=157787 Tuesday, October 29th, 2019 1:05 AM → Ms2ger joined (~Ms2ger@ptr-g1wjcuh999hln6zoxci.18120a2.ip6.access.telenet.be) 2:26 AM devsnek: There were other libraries historically used that were faster and less accurate 2:26 AM IMO accuracy is an important goal here 4:21 AM ⇐ Ms2ger quit (~Ms2ger@ptr-g1wjcuh999hln6zoxci.18120a2.ip6.access.telenet.be) Ping timeout: 276 seconds 7:05 AM → Ms2ger joined 8:39 AM <+devsnek> littledan: my goal here is accuracy, yes 8:39 AM <+devsnek> v8 originally had some optimizations that really killed the accuracy, i replaced those with fdlibm 8:40 AM <+devsnek> but then it turns out fdlibm isn't doing so great either 8:58 AM *facepalm emoji* 8:59 AM <+rkirsling> you can just type 🤦 if you're on IRCCloud ;) 9:00 AM <+devsnek> right now v8 says 10 ** -5 is 0.000009999999999999999 9:03 AM Eh, close enough 9:04 AM <+devsnek> :( 9:07 AM how good is the ieee rep for 0.000001 ? 9:07 AM awww e-15 error on that one, so it stores it pretty well 9:09 AM <+devsnek> https://gc.gy/40070350.png 9:11 AM <+rkirsling> that's fdlibm's fault? huh, you'd think it'd be of broader concern than just implementing JS then... 9:12 AM <+devsnek> well it turns out everything uses std::pow 9:12 AM <+devsnek> not fdlibm 9:12 AM <+devsnek> in this one case 9:12 AM <+rkirsling> ah 9:13 AM <+devsnek> but v8 wants the algo to be explicit in codebase 9:13 AM <+devsnek> since you could in theory compile v8 with a version of libstdc++ where std::pow is just "return 42" 9:14 AM <+devsnek> so then i tried to find one of these algorithms powering std::pow 9:14 AM <+devsnek> but i couldn't find any 9:14 AM <+devsnek> so i asked here 9:15 AM <+rkirsling> is that a general Chromium worry? 9:15 AM <+devsnek> 🤷🏻 9:15 AM <+devsnek> i hadn't really heard of it as a concern before 9:16 AM <+devsnek> assumedly more than just std::pow would break with a bad libstdc++ 9:16 AM <+rkirsling> yeah. 9:16 AM <+rkirsling> seems like the answer to that is just "then they would have a very odd V8 build, but intentionally"