Latest post

Nov 19, 2024, 17:57:17

The <input type="number"> is so evil. I thought that entering 1e309 will have its value return 1e309 and that converting it to a number will give me infinity. Nope, it will return an empty string, and converting it to a number gets me zero. Note that 1e309 IS A VALID FLOATING-POINT NUMBER according to the #HTML standard.

#web #webdev #javascript #coding

follow me on Mastodon

Articles

  • I want to invent a better way to read numbers

    Reading numbers in English is a pain. I want to invent a better way to read numbers!

  • The longest all-11 substring of a random bit string

    Given your probability of breaking the combo at each note, what is the probability distribution of your max combo in the rhythm game chart? I considered the problem seriously!

  • I made this, for the number of days in a week is prime

    The number of days in a week is prime, so we cannot utilize weekly periods to help us remember periodical events unless the period is a multiple of 7. However, there may be something that we need to get reminded of which happens once per two days or three days. For example, I wash my hair once per two days and wash my clothes once per eight days. To solve the problem, I wrote a Ruby program to help remind me of those routines.

  • Using ntfy to warn me when my computer is discharging

    I use udev and systemd to send a notification to my phone via ntfy automatically whenever my laptop is discharging.

  • How to construct mechanics in higher dimensions?

    We can derive the equation of motion for mechanical systems in a Galileo universe with ι\iota time dimensions and χ\chi space dimensions by generalizing the principle of relativity and Hamilton’s principle.

  • When a supersonic airplane flies over your head

    Suppose a supersonic airplane has Mach number MM. It flies horizontally. At some time, it flies past over your head at height hh. Then, the distance between you and it when you have just heard it is MhMh.

  • Finding curvature radius physically

    Sometimes the curvature radius of a curve can be found by using physical methods although it seems that you must use calculus to find it. In this article, the curvature radius of the curve x2=2pyx^2=2py at the point where the curvature radius is smallest is found by using physical methods without using calculus (with only high school knowledge). The answer is that the smallest curvature is exactly pp, and the point with smallest curvature is the vertex.

  • A whirling point charge

    In the vacuum, inside a fixed ring of radius RR with fixed charge QQ uniformly distributed, there is a point charge with charge qq and mass mm moving in the plane of the ring due tue the electrostatic force. It moves in the small region around the center of the ring, and the motion is periodic along a closed curve. The area of the region enclosed by the curve is SS. Denote the distance from the center to the point charge as rr, and rRr\ll R. Find the magnetic induction BB at the center of the ring.

  • Solving ODE by recursive integration

    By recursively integrating according to xn+1 ⁣(t)t0tf ⁣(xn ⁣(s),s)ds+Cx_{n+1}\!\left(t\right)\coloneqq\int_{t_0}^tf\!\left(x_n\!\left(s\right),s\right)\,\mathrm ds+C from x0 ⁣(t0)Cx_0\!\left(t_0\right)\coloneqq C, we can get the solution of the ODE x ⁣(t)=f ⁣(x ⁣(t),t)x'\!\left(t\right)=f\!\left(x\!\left(t\right),t\right) with initial conditions x ⁣(t0)=Cx\!\left(t_0\right)=C as the limit of the sequence of functions.

  • An example of non-uniform elements: heavy elastic rope

    To illustrate the concept about non-uniform elements, we study a simple problem: suppose a uniform heavy elastic rope has mass mm, original length L0L_0, and stiffness kk, and find the mass distribution and length of it when hung vertically. We can use the element method to solve this problem, but the elements are non-uniform in terms of length. The elements add up to get the total length L=mg2k+L0L=\frac{mg}{2k}+L_0.

subscribe via RSS