• 0 Posts
  • 14 Comments
Joined 3 years ago
cake
Cake day: December 20th, 2021

help-circle


  • drspod@lemmy.mlto196@lemmy.blahaj.zone📄 rule
    link
    fedilink
    arrow-up
    0
    ·
    1 month ago

    Correct. A piece of paper with the golden (aspect) ratio would have the property that if you remove the large square (with side length equal to the shortest side of the rectangle) then the remaining rectangle has the same (golden) aspect ratio.

    The ISO216 ratio of 1:sqrt(2) has the property that if you cut the paper in half then both halves have the same aspect ratio as the original larger piece.

    People tend to confuse these two properties as they both involve the remaining rectangle having the same aspect ratio as the original piece, but the process to bisect the sheet is different.




    • if square_root takes a uint64_t argument then it should return a uint32_t
    • x = (x + (s / x)) / 2; This update of the test value uses integer divisions which means it is not guaranteed to converge (due to the truncation moving your approximation further away than the previous iteration). You should also check that x > 0 to avoid accidental division by zero.
    • it looks like seed is trying to calculate pow(10, log_100(x)) in some way, but it has bugs, for example a < 10 is true for radicand values of 100-999, 10000-99999, 1000000-9999999 etc. which probably isn’t what you want. An easier way to estimate a starting value for the first iteration would be to take a number that has half as many bits as the input, since we know that if a number X uses K bits then its square root will use K/2 bits. You can use a method to calculate the position of the most significant set bit in the input and then use 2^(k/2) as the seed.
    • for ease of readability and checking correctness, I would recommend that you don’t use implicit casts to float for arithmetic and avoid implicit casts back to integers with the results. Declare floating point variables when you want floating point arithmetic and then use explicit casts back to ints to make it clear to the reader (reviewer) that any truncation of the result is intentional. This is considered good practice when writing C. You can compile with -Wall -Werror (with gcc) to enforce those checks and make them compile errors that you must fix.



  • Back in the early 90s someone told me, “source code gets lost, but binaries live forever.” It was true back then (because of the way people shared files by trading floppy disks) but I think today in the open source ecosystem, actually the opposite is true.

    A project may not get packaged or released anymore, but as long as the source code is still available, new people can make use of that work and make derivative works with their own modifications.

    I worry that too much of our collective community work is siloed in places like GitHub that one day may throw out old repositories while spring cleaning. I hope that we see the same level of effort put into source code preservation that organizations like the Internet Archive put into binary preservation.






  • It sounds like they have some nice improvements, but I wonder why they didn’t contribute them back to the original restic project.

    I also wouldn’t rely on an immature piece of software to handle backups - you want to avoid as many risk factors as possible with backups, since when you need to restore you really need it to work.