More from Maggie Appleton
Practical tools for design engineers to explore possible futures through speculative design
Why we need richer, thicker interfaces and better boundary objects for collaborative planning with agents
A delayed education on the trenches and scales of suffering
Why we need collaborative AI engineering and a tour of Ace: the multiplayer coding workspace
More in programming
In 1978, the ACM published an algorithm by Robert Morris for counting large numbers of events in small registers. It uses one byte to keep track of the approximate logarithm of the count, and randomly increments the logarithm with a probability that scales with the value of the count. You can tune the range and precision of the counter by adjusting the base of the logarithm. Morris suggests pre-calculating a table of probabilities so that no difficult calculations are needed at runtime. Recently I learned from emsenn about a 2009 paper by Miklós Csűrös titled approximate counting with a floating-point counter. It changes Morris’s algorithm to use a binary log-linear counter instead of a pure logarithm. It reminded me of my hg64 log-linear histograms, so I thought it would be fun to implement, especially since the algorithm can be made shorter and faster. representing a counter We need to choose the number of bits to use for the exponent and mantissa of each approximate floating point counter. Typically the exponent will be 5 or 6 bits, corresponding to an unpacked exact counter of 32 or 64 bits. The mantissa will typically be the rest of an 8 or 16 bit integer (though languages such as Zig and C23 allow more adventurous integer sizes). I’ll call the approximate counter type usmol and the unpacked counter type ubig. #define EXPBITS 5 #define SIGBITS 3 typedef unsigned _BitInt(EXPBITS+SIGBITS) usmol; typedef uint32_t ubig; static_assert(sizeof(ubig) * 8 == 1 << EXPBITS, "ubig must match EXPBITS"); It’s straightforward to extract the exponent and mantissa from a usmol counter. Unpacking a usmol into a ubig is slightly tricky. Like hg64 and IEEE754, normal numbers (with a nonzero exponent) have an implicit leading bit, and denormal numbers (exponent is zero) do not. The effect is that small counts are represented exactly in a usmol (up to 2*MANTISSA, covering denormal numbers and exponent == 1), and larger counts are shifted by the exponent. (I don’t need the inverse conversion here, but it is used by hg64 to map a sample to a histogram bucket, truncating the value by shifting right.) #define MANTISSA (1 << SIGBITS) static inline ubig exponent(usmol approx) { return(ubig)(approx / MANTISSA); } static inline ubig mantissa(usmol approx) { return(ubig)(approx % MANTISSA); } static inline ubig unpack(usmol approx) { ubig e = exponent(approx) - 1; ubig m = mantissa(approx) | MANTISSA; return(approx < MANTISSA ? approx : m << e); } bumping a counter Because binary floating point uses logarithms in base 2, we need the probability of incrementing the counter to scale with 2^-e. Specifically, we want the probability of increasing the counter to be 100% when its exponent is 0 or 1, 50% when the exponent is 2, 25% when it is 3, etc. Csűrös does this by getting a random bit e times in a loop and incrementing the counter if they are all zero. A more efficient way to do this on a computer is to get a ubig word full of random bits and count the leading or trailing zeroes. There are a variety of bit scan functions that differ in how they number bits and what they do when the word is entirely zero. The POSIX ffs() family has the advantage of no undefined behaviour, but it weirdly counts from one. However this oddity turns out to match the way denormal numbers give our exponent an off-by-one bias. So for instance, when our exponent is 2 and we want a 50% probability, we want ffs() to return 2 or more. OK, that determines when to increment the mantissa given a particular exponent. But how does the exponent get incremented? Like Csűrös, we put the exponent immediately to the left of the mantissa; when the mantissa overflows, it rolls over to zero and the exponent ticks up. No special cases are needed. The resulting code is short: usmol bump(rng_t *rng, usmol approx) { ubig r = ubig_random(rng); ubig z = (ubig)ffsll((long long)r); ubig e = exponent(approx); return(approx + (z >= e)); } considerations Morris allows you to smoothly tune the allowable range and precision of a counter by adjusting the base of the logarithm. By contrast, Csűrös has very lumpy 2^2^n choice of ranges; that isn’t necessarily bad because it’s normal for programmers to have to choose between uint32_t and uint64_t. Morris uses a lookup table to determine the probability of incrementing, which is tolerable for an 8 bit counter, but it can get large for wider counters. Csűrös just uses a few instructions and bigger counters don’t need much more. So I don’t think either algorithm is clearly better than the other, except that Csűrös has the winning fun factor of bithacking a bespoke floating point format.
Parallelize discovery and execution, but serialize judgement.
Sending email is easy. Making sure good emails land where they should is not.
This is an article about user preferences. It is also about the larger framework of decisions designers sit inside of when employing them, and the outcomes that they can create. I wrote this article because the power dynamics and downstream effects surrounding user preferences is something multiple accessibility practitioners I know are aware of. My, and their thinking about these dynamics and end results is worth being aware of. Discussing the concerns that surround how user preferences are introduced can also be, ahem, counterproductive to healthy working relationships when brought up in the moment. So, I am writing it out here instead for people to read and digest at their own pace. What are user preferences? For the uninitiated, user preferences are different modes you can set in your operating system to help you use a digital device. Examples include, but are not limited to: Dark mode, Reduced motion, Reduced transparency, Increased contrast, Forced colors, etc. All of these user preferences enable, improve, and enhance someone’s ability to operate digital experiences. Consequently, they can be considered assistive technology. However, someone enabling user preferences isn’t a given. This is worth emphasizing because the existence of user preferences can also serve as an excuse during the product or feature design process. Just because a user preference exists does not mean someone who could benefit from it is using it There are a whole host of reasons as to why this is. Here’s a few: Low digital literacy means someone does not know how to navigate to their operating system preferences, or that said preferences even exist in the first place. Someone might not know they have a disability, and consequently will not seek out a related user preference. Related, internalized ableism means someone does not think the accessibility section of operating system preferences applies to them. A device might be locked down by someone’s employer, with large swaths of functionality set to be restricted. A device may be shared due to economic circumstance, where individuals in disadvantaged communities share a device or access one from locations like a public library or shelter. A device’s operating system may not be updated to a version where support for the user preference was added. etc. An example of where the existence of user preferences gets abused A common example I’ve had to contend with is color contrast. A common response to contrast issues being brought up is to propose setting a high contrast theme that kicks in if someone has the increased contrast user preference enabled. This is done in an attempt to avoid the minimum contrast ratio demanded by the Web Content Accessibility Guidelines (WCAG) requires. More abstractly, this response enables a designer avoiding deeper inquiry into their sense of aesthetics. This in turn avoids questioning how personal opinions around taste impact the audiences they ultimately serve. The reason why a low-contrast-experience-as-default is a non-starter is obvious if you understand what the spirit of WCAG is getting at. It is also why a website offering an increased contrast theme switcher using color values in the UI that are too low contrast is also not a viable approach. That reason is content in its default state may be unable to be perceived. And if it cannot be seen, it cannot be read or used. It’s as simple as that. These examples, and other related ones compels a change of mindset. Accessible by default, opt-out by choice Disability intersecting with digital experiences creates a range of outcomes from mild annoyance, to hard barriers, and even direct harm. This intersection compels an approach that means proactively accommodating the widest swath of unknown people with unknown preferences, capabilities, devices, and circumstances as the default. Another example: I know someone who had a seizure because of a full-screen animation a website played. The animation implementation itself honored a reduced motion user query. However, the person did not know that the reduced motion user preference existed and consequently did not enable it. Are we to blame them? People who work in the digital accessibility space are already aware of this accessible-by-default approach. It is why the WCAG is phrased the way it is. As a positive example of this, this is why GitHub underlines its links by default now, but also enables you to switch link underlines off. However, this accessible by default, opt-out by choice mindset isn’t always present for designers. This brings about three tough, yet vital questions that need to be asked, and this article’s format is a safer way to provide the larger surrounding context of why they need to be asked. Who do you want to exclude? Asking this question in a structured way, in good faith at the beginning of a project is a great way to help build awareness and consensus. This question is what an in-house accessibility practitioner is likely thinking when they hear a proposal to present an accessible alternative hidden away under a user query. I will also note that asking it directly at later stages of the design process isn’t feasible in most professional environments. What are you deciding? Here’s another question your peer really can’t ask in the moment. Accessibility practitioners tend to think of their work as an output coming from an ethical or harm prevention way of thinking. Unfortunately, this kind of thinking isn’t always the most compelling or effective strategy in contemporary business culture. Because of this, there are three more pragmatic lenses we can view design choices through: Usability Constraining the methods of operation of a digital experience to work in only the ways you personally use something is a decision. And that decision limits how usable the experience is to others. In opposition to this artificially-applied constraint, conferring the ability for someone to efficiently navigate and take action on a digital experience is one of the main jobs you have as a designer. This applies to both the public and private sectors. Profitability Another main job of designers working in the private sector is to enable the creation and continuation of profit, and profitability is impacted by usability. To that point, poor usability leads to less profitability if your product is actively competing in the market. Consequently, choosing to limit usability also chooses to limit profitability. Here, in the context of lucrative SaaS contracts I would like to call out both the tyranny of the majority and also the correlations between age, disability, and decision-making power. Law At the end of the day it is a court—and not you—that decides whether or not a barrier is present for a disabled person using a service. Here, know two things: There is also plenty of precedent in the private sector in the United States to draw from, and also WCAG helps inform how to avoid many forms of barriers in digital experiences. I am not going to say that you are choosing to break the law when you lead with an inaccessible default. However, I will say that a jury might. Where do you want to place the burden? Learning about and enabling user preferences takes effort. Forcing disabled people to fiddle with obscure operating system preferences places the burden on them to get basic accessibility accommodation. Also know It is a fallacy to assume the presence of an active user query means someone is accommodating their disability. For example, I use a reduced motion media query on my laptop and phone because I am impatient and want OS transition effects to get out of the way and take as little time as possible. As alluded to earlier with my comments on age and decision-making power, it is also a fallacy to assume the presence of disability or use of a user query means a lack of ability, competency, or value. This mindset is largely due to how pervasive ableism—and how it shapes ideas about disability—is in our culture. Try sitting with this To quote my friend Soren: User preference settings or accessibility settings cannot replace our responsibility to design and build accessible apps and websites. The ideas and viewpoints shared in this post article are something you may not be exposed to due to both a historic lack of disability theory in design education, and also a lack of organizational prioritization of accessibility in design practice. Your ideas and values may be challenged by this, as well as your aesthetic sensibilities. Spend some time reflecting on why you feel this friction and unease, as well as the power and responsibility you wield as someone who creates digital experiences.
The US is updating its primary spatial reference system, replacing NAD 83 with NATRF 2022 and other systems.