艹,我一个也没写对…… 全错了,我真的不敢相信
测试输入包含 5 个 token,也就是说是:
Launch systemStack 29903450318121
= 0
Finish systemStack in 341.87micros
Launch AdtStack 29903455998170
= 132609292
Finish AdtStack in 1.790674ms
Launch Nashorn JS 29903458052996
= -1.524697469698283E13
Finish Nashorn JS in 334.887835ms
我找 Ruby 问了也是一个结果,这 TMD 怎么可能?
为了保证不是优先级的问题,我决定手工结合一下看看:
=> -15246247231449
这么说我的解析算法写错了?
886669351
emmm...
测试输入包含 5 个 token,也就是说是:
492 / 5912 / 40 * 2485 - 7688 * 94 * 26175 * 806 - 228 * 51 + 97779这样。
Launch systemStack 29903450318121
= 0
Finish systemStack in 341.87micros
Launch AdtStack 29903455998170
= 132609292
Finish AdtStack in 1.790674ms
Launch Nashorn JS 29903458052996
= -1.524697469698283E13
Finish Nashorn JS in 334.887835ms
我找 Ruby 问了也是一个结果,这 TMD 怎么可能?
为了保证不是优先级的问题,我决定手工结合一下看看:
(( (((492 / 5912) / 40) * 2485) - (((7688 * 94) * 26175) * 806) ) - (228 * 51) ) + 97779
=> -15246247231449
这么说我的解析算法写错了?
/usr/lib/jvm/java-1.8.0/bin/java... CalcMain^D
(( (((492 / 5912) / 40) * 2485) - (((7688 * 94) * 26175) * 806) ) - (228 * 51) ) + 97779
886669351
emmm...
This media is not supported in your browser
VIEW IN TELEGRAM
Σ 492 / 5912 / 40 * 2485 - 7688 * 94 * 26175 * 806 - 228 * 51 + 97779生艹,是真的了,是Calc自己都有问题
= Just ((((((492.0 / 5912.0) / 40.0) * 2485.0) - (((7688.0 * 94.0) * 26175.0) * 806.0)) - (228.0 * 51.0)) + 97779.0)
= -1.524624723144383e13
GNU Bc 和我之前写的 BinOps 都正常
((((((492 / 5912) / 40) * 2485) - (((7688 * 94) * 26175) * 806)) - (228 * 51)) + 97779)简直奇了,它是怎么弄出886669351这个结果的??? 🌚🌝???
好像是算错了。
Ruby 得 18915939600
它得 1736070416
((7688 * 94) * 26175) Ruby 得 18915939600
irb(main):001:0> ((7688 * 94) * 26175)=> 18915939600
它得 1736070416
((7688 * 94) * 26175)1736070416
^D
问: 722672.times(26175) 是多少?
Kotlin:
Ruby:
???原来整数误差也可以跨语言了???
Kotlin:
722672.times(26175) == 1736070416 Ruby:
722672*26175 => 18915939600???原来整数误差也可以跨语言了???
Forwarded from dnaugsuz
为什么 GNU bc, Ruby, Lua, NodeJS 全都是默认浮点数?那我的测试该怎么写?这些辣鸡脚本语言!
艹,才想起来很多脚本语言里数值类型混乱不堪;Ruby 曾经还分过 Fixnum 和 Bignum,肯定是这些在诬陷正直的 JVM。
这个时候就需要鼓吹我们正直的 JVM、CLR、C++,不与一些辣鸡脚本语言同流合污、随手胡乱对待数值类型。
明明写着看着是 1,其实是 1.0 的这种语言和辣鸡 JavaScript 是没有灵魂上的区别的。
……可惜正直的语言还不如 Python3、PHP 火,可惜啊可惜
明明写着看着是 1,其实是 1.0 的这种语言和辣鸡 JavaScript 是没有灵魂上的区别的。
……可惜正直的语言还不如 Python3、PHP 火,可惜啊可惜
duangsuse::Echo
我在想,其实递归下降法本身就很简单了,所以不一定必须弄太多Feeder什么的…… 还有『随机』MarkReset 很多文法都是LL(1)的,搞这么多纯属多余(虽然也不一定没用) 既然需要Mark/reset的时候很少,不如就只针对Peek进行扩展,让它能够随便(惰性地)支持MarkReset,不为那种File input的情况考虑了(反正PeekStream也足够高效了) 然后 SourceLocation 不一定非得Mixin,之前在ParserKt算行号的代码测试过可以拿到 SourceLocation…
typealias Atom = Int这时候就体现你用 Typealias 的一个好处,就是想用用、不想用随时换,不会找不到该改哪
算法请参照:
https://github.com/duangsuse-valid-projects/three-kt-files/blob/master/src/commonMain/kotlin/Calc.kt#L103
跑分实现在:
https://github.com/duangsuse-valid-projects/three-kt-files/blob/master/src/jvmMain/kotlin/BasicBench.kt (lib)
https://github.com/duangsuse-valid-projects/three-kt-files/blob/master/src/jvmMain/kotlin/CalcBench.kt
https://github.com/duangsuse-valid-projects/three-kt-files/blob/master/src/commonMain/kotlin/Calc.kt#L103
跑分实现在:
https://github.com/duangsuse-valid-projects/three-kt-files/blob/master/src/jvmMain/kotlin/BasicBench.kt (lib)
https://github.com/duangsuse-valid-projects/three-kt-files/blob/master/src/jvmMain/kotlin/CalcBench.kt
GitHub
duangsuse-valid-projects/three-kt-files
2019/11/10: Three Kotlin files (RingBuffer, DiffAlgorithm, NumEqualize, etc.) - duangsuse-valid-projects/three-kt-files
其实啥时候 Harray Ying 为什么不去学学范畴论呢…… 最近偏工程的事情很多,没时间看这篇文章了……
Forwarded from Math notes | 数学笔记 (Harry Ying)
Harry Ying's blog
Abstract Algebra Learning Log - Preliminaries
Recently, I have been working on Abstract Algebra which has derived category theory and exposes its strong relation with computer science.
Brief Introduction
All these learning logs will be ba
Brief Introduction
All these learning logs will be ba
Math notes | 数学笔记
https://lexuge.github.io/posts/abstract-algebra-learning-log-preliminaries/
Recently, I have been working on Abstract Algebra which has derived category theory and exposes its strong relation with computer science.
其实就是范畴论的…… 看到 Log 我第一时间想到的是对数(logarithm)……
难怪,代数的抽象
为了确认 title 里
其实就是范畴论的…… 看到 Log 我第一时间想到的是对数(logarithm)……
难怪,代数的抽象
为了确认 title 里
Log 的含义其实我还是忍不住打开看了,那就顺便翻译一下。Abstract Algebra Learning Log - Preliminaries by Harry Yin
《抽象代数》学习笔记 — 预章
—
Recently, I have been working on Abstract Algebra which has derived category theory and exposes its strong relation with computer science.
最近我在学习抽象代数,自它派生出了范畴论,它与计算机科学有很大联系。
—
Brief Introduction
简要引言
—
All these learning logs will be based on one online and free textbook (2019 Version), naming Abstract Algebra which is licensed under the GNU FDL.
This learning log is basically in two parts, one is my own understandings or complementions to some of the parts, another part is my own answers to part of the Exercises section in the end of the chapter. And succeeding learning logs will mainly based on this form too.
First part may contain works in the textbook itself, therefore, this series of posts is licensed under the GNU FDL either.
这些笔记都是基于一个免费的网上教材(2019版),它以 GNU FDL 开源,名字叫《抽象代数》Abstract Algebra。
我把笔记大致分成了两部分,一部分是我自己的理解和补充,另一部分则是我对书中节末练习的解答。
后继的学习笔记也会基本保持这个形式。
第一部分可能包含教材里既有的内容,所以,这一系列文章也以 GNU FDL 许可证发布。
—
Understandings and complementions to textbook
部分一,对教材内容的理解和补充
—
Page 6, Proof of De Mogran's Laws
P6,De Mogran 定律的证明
—
1. $(A\cup{B})' = (A'\cap{B'})$
We define two statements, $p$ and $q$, representing $x\in{A}$ and $x\in{B}$ respectively.
statement $x\in{(A\cup{B})}'
\Leftrightarrow{\neg{ (p\lor{q}) }}
\Leftrightarrow{ (\neg{p}\land{\neg{q}}) }
\Leftrightarrow{x\in{ (A'\cup{B'}) }}.
$ (The relation between $\neg{ (p\lor{q}) }$ and $(\neg{p}\land{\neg{q}})$ can be deduced by simply enumerating through all the possible values of $p$ and $q$, e.g. $true$ or $false$ for statements).
Thus, $\forall{x}\in{(A\cup{B})'} \rArr{ x\in{ (A'\cap{B'}) } }
\rArr{ (A\cup{B})' } \supset{ A'\cap{B'} }$. Conversely, we can prove $(A\cup{B})'\subset{A'\cap{B'}}$.
{— 注:原文使用 Emacs org mode 排版,这里 TeX 上稍有修改,原文采用 GNU FDL 许可证 —}
…… 算了这么多数学公式,我干脆用 TeX 排版了发吧
《抽象代数》学习笔记 — 预章
—
Recently, I have been working on Abstract Algebra which has derived category theory and exposes its strong relation with computer science.
最近我在学习抽象代数,自它派生出了范畴论,它与计算机科学有很大联系。
—
Brief Introduction
简要引言
—
All these learning logs will be based on one online and free textbook (2019 Version), naming Abstract Algebra which is licensed under the GNU FDL.
This learning log is basically in two parts, one is my own understandings or complementions to some of the parts, another part is my own answers to part of the Exercises section in the end of the chapter. And succeeding learning logs will mainly based on this form too.
First part may contain works in the textbook itself, therefore, this series of posts is licensed under the GNU FDL either.
这些笔记都是基于一个免费的网上教材(2019版),它以 GNU FDL 开源,名字叫《抽象代数》Abstract Algebra。
我把笔记大致分成了两部分,一部分是我自己的理解和补充,另一部分则是我对书中节末练习的解答。
后继的学习笔记也会基本保持这个形式。
第一部分可能包含教材里既有的内容,所以,这一系列文章也以 GNU FDL 许可证发布。
—
Understandings and complementions to textbook
部分一,对教材内容的理解和补充
—
Page 6, Proof of De Mogran's Laws
P6,De Mogran 定律的证明
—
1. $(A\cup{B})' = (A'\cap{B'})$
We define two statements, $p$ and $q$, representing $x\in{A}$ and $x\in{B}$ respectively.
statement $x\in{(A\cup{B})}'
\Leftrightarrow{\neg{ (p\lor{q}) }}
\Leftrightarrow{ (\neg{p}\land{\neg{q}}) }
\Leftrightarrow{x\in{ (A'\cup{B'}) }}.
$ (The relation between $\neg{ (p\lor{q}) }$ and $(\neg{p}\land{\neg{q}})$ can be deduced by simply enumerating through all the possible values of $p$ and $q$, e.g. $true$ or $false$ for statements).
Thus, $\forall{x}\in{(A\cup{B})'} \rArr{ x\in{ (A'\cap{B'}) } }
\rArr{ (A\cup{B})' } \supset{ A'\cap{B'} }$. Conversely, we can prove $(A\cup{B})'\subset{A'\cap{B'}}$.
{— 注:原文使用 Emacs org mode 排版,这里 TeX 上稍有修改,原文采用 GNU FDL 许可证 —}
…… 算了这么多数学公式,我干脆用 TeX 排版了发吧
我算是彻底见识了数学的『严谨』了,排除英文表达外我都无法好好地说明啥是啥了,虽然是严谨但是为什么不直接用工具来验证表达是严谨的?