avatarAvi Kotzer

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

3786

Abstract

arison operators, and bitwise operators on this type too.</p><p id="c4da">It’s important to note that there is another type, called <code>bytes</code> which is different from the above in that it is a dynamically sized array, and not a value type but a reference type. It is basically shorthand for <code>byte[]</code>.</p><p id="ad39">When you can limit the length of your data to a predefined amount of bytes, it is always good practice to use some of <code>bytes1</code> to <code>bytes32</code> because it is much cheaper.</p><h2 id="0118">Enums</h2><p id="aea7"><b>Enums</b> in Solidity are a way to create user-defined types. Enums are explicitly convertible to integer types, but not implicitly. Enum values are numbered in the order they are defined, starting from 0.</p><p id="ed00">Enums are not part of the ABI (Application Binary Interface — more on this in a later lesson, but it’s basically how you encode Solidity code for the Ethereum Virtual Machine, and how you get data back). This means that if your function returns an <code>enum</code> for example, it will be automatically converted to a <code>uint8</code> behind the scenes. The integer returned is just large enough to hold all enum values. With more values, the size gets increased too (<code>uint16</code> and up).</p><p id="cdb6">The below code, taken from the <a href="https://docs.soliditylang.org/en/v0.4.24/index.html">Solidity docs</a>, defines an enum with four possible values, creates a variable of that enum named <code>choice</code> and a constant called <code>defaultChoice</code>that will hold a default value.</p><div id="cf29"><pre><span class="hljs-keyword">enum</span> <span class="hljs-title class_">ActionChoices</span> { GoLeft, GoRight, GoStraight, SitStill } ActionChoices choice; ActionChoices <span class="hljs-type">constant</span> <span class="hljs-variable">defaultChoice</span> <span class="hljs-operator">=</span> ActionChoices.GoStraight;</pre></div><p id="66a9">Now we can define some functions to interact with our <code>enum</code>.</p><div id="c0bb"><pre><span class="hljs-title function_"><span class="hljs-keyword">function</span> <span class="hljs-title">setGoStraight</span></span>() <span class="hljs-keyword">public</span> { choice = ActionChoices.GoStraight; }

<span class="hljs-title function_"><span class="hljs-keyword">function</span> <span class="hljs-title">setChoice</span></span>(ActionChoices <span class="hljs-keyword">new</span><span class="hljs-type">Choice</span>) <span class="hljs-keyword">public</span> { choice = <span class="hljs-keyword">new</span><span class="hljs-type">Choice</span>; }</pre></div><p id="6bc2">The first one simply sets the <code>choice</code> to <code>GoStraight</code> while the second one sets it to the choice that the caller passes into the function. As we can see after deployment, the <code>setChoice</code> function expects a <code>uint8</code> value, which corresponds to the <code>enum</code> value declared at that number.</p><figure id="e997"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*1pKNPVy4UUBCSLi2-SIckg.png"><figcaption>Testing enums in Remix</figcaption></figure><p id="7917">If we want to get the value of <code>choice</code> and <code>defaultChoice</code>, we can define the following functions:</p><div id="1f02"><pre><span class="hljs-keyword">function</span> <span class="hljs-title">getChoice</span>() public view returns (ActionChoices) { <span class="hljs-keyword">return</span> <span class="hljs-type">choice</span>; }</pre></div><div id="43e7"><pre><span class="hljs-function">function <span class="hljs-title">getDefaultChoice</span>() <span class="hljs-keyword">public</span> pure <span class="hljs-title">returns</span> (<span class="hljs-params"><span class=

Options

"hljs-built_in">uint</span></span>)</span> { <span class="hljs-keyword">return</span> <span class="hljs-built_in">uint</span>(defaultChoice); }</pre></div><p id="c2f2">As we can see if we try this out in Remix, the first function returns a <code>uint8</code> while the second returns a <code>uint256</code>.</p><figure id="e514"><img src="https://cdn-images-1.readmedium.com/v2/resize:fit:800/1*jmaOFb9GhXz7FWC4ONMa_A.png"><figcaption>Testing enums in Remix</figcaption></figure><h2 id="3c7c">Fixed point numbers</h2><p id="2ecc"><b>Fixed point numbers </b>represent fractional numbers by storing a fixed number of digits of their fractional part. No matter how large or small the fractional part is, it will always use the same number of bits.</p><p id="cdcd" type="7">Fixed point numbers are not fully supported by Solidity yet. They can be declared, but cannot be assigned to or from.</p><p id="f872">We can differentiate between signed fixed point numbers, declared with the <code>fixed</code> keyword, and unsigned fixed point numbers, declared with the <code>ufixed</code> keyword.</p><p id="3c1c">It can also be declared as <code>fixedMxN</code> or <code>ufixedMxN</code> where <code>M</code> represents the number of bits the type takes, and <code>N</code> represents the number of decimal points. <code>M</code> has to be divisible by 8 and a number between 8 and 256. <code>N</code> has to be a number between 0 and 80.</p><p id="96e1">They function with the following operators:</p><ul><li>Comparisons: <code><=</code>, <code><</code>, <code>==</code>, <code>!=</code>, <code>>=</code>, <code>></code> (evaluate to <code>bool</code>)</li><li>Arithmetic operators: <code>+</code>, <code>-</code>, unary <code>-</code>, unary <code>+</code>, <code>*</code>, <code>/</code>, <code>%</code> (remainder)</li></ul><h2 id="09b7">Conclusion</h2><p id="bd3a">In this lesson, we looked at what value types are available in Solidity and how each one works.</p><p id="28de">Thank you for staying with us till the end. If you enjoyed reading this piece please keep in touch and follow Solidify to keep up with our lessons on Solidity. In the upcoming articles, we will deep dive into the intricacies of the language, progressing from beginner to advanced level.</p><p id="067c">If you are new to Solidity, check out the previous lessons about setting up a local development environment and writing your first smart contract.</p><div id="6b76" class="link-block"> <a href="https://readmedium.com/how-to-setup-your-local-solidity-development-environment-c4c8195810f3"> <div> <div> <h2>How to Setup Your Local Solidity Development Environment</h2> <div><h3>Get started with smart contract development</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*HHko-o9m1sVngmTeRVYgKA.jpeg)"></div> </div> </div> </a> </div><div id="3ad1" class="link-block"> <a href="https://readmedium.com/lesson-1-your-first-solidity-smart-contract-1ba7e641f9a3"> <div> <div> <h2>Lesson 1: Your First Solidity Smart Contract</h2> <div><h3>In the previous lesson, we looked at how to set up your local Solidity development environment. Here we will continue…</h3></div> <div><p>medium.com</p></div> </div> <div> <div style="background-image: url(https://miro.readmedium.com/v2/resize:fit:320/1*7r7HSYkbn73NrmR_skvh5w.jpeg)"></div> </div> </div> </a> </div></article></body>

Giardia

The tiny parasite with huge eyes

Image by Dr. Stan Erlandsen

Today’s New York Times Spelling Bee letters:

Art: Iva Reztok

A, G, I, N, P, R, and center D (all words must include D)

Merriam-Webster says…

Credit: merriam-webster.com

Silly little dictionary! Don’t you know that giardia can’t possibly be a word if The New York Times says it ain’t?

For a complete list of rejected words, check out the Spelling Bee Master.

What’s your favorite dord* from today’s puzzle?

My Two Cents

I know that discussing a diarrhea-inducing parasite may not be the best way to attract readers on a Sunday afternoon ––or any afternoon, for that matter–– so just take this as a public service announcement. And, although I do have a medical background and know what I’m talking about here, if you are ever feeling ill for any reason, go talk to a doctor. And by doctor I mean your physician, not Dr. Google. A friend of mine has a mug he likes to quote:

Credit: amazon.com

Did you know that the term parasite originally referred to the assistants of priests in Ancient Greece? They parasites would help the priests with ritual sacrifices, after which they would eat together. The Greek para- means “beside” or “next to”, while sitos means “grain” or “bread”. Later the term began to be used for one certain people in Ancient Greece who would dine or even live with the rich, earning that benefit by flattery, entertainment, and even humiliation.

Only much much later did parasite come to mean “an organism living in or on another living organism, obtaining from it part or all of its organic nutriment.”

The agent

The Giardia genus was named for Alfred Mathieu Giard, a 19th-century French biologist who was one of the first to describe this parasite. The species lamblia, which is the one that infects humans, was named for Czech physician Vilem Dusan Lambl. The first definition provided by the dictionary is capitalized, which a Spelling Bee no-no, but the second meaning isn’t. Which means giardia should be accepted as a valid word.

The oldest articles in The New York Times about this parasite date to 1970. A piece that came out in December of that year describes how “Physicians attached to the State Department and others at the Center for Disease Control in Atlanta are investigating a series of outbreaks of parasitic disease that has affected Americans traveling to the Soviet Union.” The article then goes on to describe the infection thusly:

The illness that afflicted the tourists to Leningrad is not “traveler’s diarrhea,” which is an entity of unknown cause that usually strikes people for a day or so just after their arrival in a foreign country. A pear-shaped parasite, called giardia lamblia, is what made these tourists ill. The parasite has two nuclei that “give the organism the appearance of a face with two large eyes,” when doctors peer at it under a microscope, Dr. Ivan L. Bennett Jr. of the New York University Medical School has said.

A face with two large eyes?

Credit: CDC / Janice Haney Carr

The above image came from an electron microscope. Which might make people take the giardia more seriously than the typical illustrations used years ago:

Hi there! I’m your friendly neighborhood parasite!

That little fellow reminds me of those sea monkeys advertised in comic books in the 1960s and 70s.

Credit: Stern.de

Please don’t print this form and mail it along with $1.25. I think that offer is no longer good. Also, don’t take the giardia lightly, either. It’s able to survive outdoors for long periods of time thanks to a tough outer shell it develops during part of its life cycle. As the online Britannica explains:

G. lamblia has two life stages: a motile, replicative trophozoite stage, in which the parasite survives in the small intestines of the host, and a nonreplicative cyst stage, in which the parasite survives in the environment. Upon ingestion by a host species, trophozoites adhere to the epithelium of the small intestine, where they then divide by binary fission. Fission may result in the production of additional trophozoites or in the generation of cysts. Cysts pass through the intestines, ultimately being shed in host feces. Once in the environment, under moist conditions, dormant G. lamblia cysts can survive for weeks or even months.

The above explanation might be helped with a visual, courtesy of the CDC:

Credit: CDC

Yep, water is one of the main media through which giardia hops from host to host. It can be found in lakes and small streams, but also in public water supplies, and even in swimming pools. It can be prevalent in areas with poor sanitation. Giardia can also spread via food and person-to-person contact, including anal and anal-oral sex.

The disease

A giardia infection, or giardiasis, is an intestinal infection with symptoms that include severe stomach cramps, nausea, bloating, and diarrhea. The diarrhea can become very intense and watery, requiring hospitalization to avoid the risk of getting dehydrated. Some people, however, show very mild symptoms or none whatsoever.

The disease can go away on its own after a few weeks––your antibodies and T cells help with that–– but can leave you with digestive problems for a long time. Some people develop lactose intolerance as a result of getting infected by giardia. (The photo at the top of today’s article shows the small intestine of a gerbil infested with giardia.)

Diagnosis is made by taking into consideration a patient’s symptoms and examining stool samples. Sometimes several samples need to be looked at. Patients with severe symptoms may receive anti-parasitic medication such as metronidazole or tinidazole. Pregnant women with giardiasis should not self- medicate to avoid exposing the fetus to these drugs, and should consult with their doctor to see what the best treatment options might be.

The best measures against giardiasis are preventive ones:

  • Purify water if you’re outdoors. Don’t drink water from shallow wells, lakes, rivers, ponds, etc., without first filtering it or boiling it for at least 10 minutes at 158 degrees Fahrenheit (70 Celsius).
  • Wash your hands and all produce. The easiest and best way to prevent giardiasis as well as many other infections. Needless to say, you should wash your hands thoroughly after going to the bathroom, changing diapers, or preparing food. Alcohol-based sanitizers can kill giardia, too, but they don’t work on the cyst form.
  • Keep your mouth closed. That’s good advice in many cases, like family Thanksgiving dinners or when in the army. But in this case, we mean you should avoid swallowing water in pools, lakes, or streams.
  • Use bottled water, especially in places where the water supply may be unsafe. In those cases, you shouldn’t use the local ice, either. It’s alos recommended that you brush your teeth with bottled water.
  • Practice safe sex, especially anal and oral-anal sex.

Remember, don’t get fooled by this cute face…

Hello! May I visit your intestine and give you horrible cramps?

Now you know. Next time your friend complains about a case of severe diarrhea, you can tell them they should check to see if it’s due to giardia. Don’t be surprised if they give you a weird look, though. Not because you’re not a doctor… but because the editors of the Spelling Bee decided that giardia is a dord*.

You can check out my previous entry on another dord* here:

*What the heck is a dord, you ask? Here’s the answer:

Spelling Bee
Language
Medicine
Parasites
Health
Recommended from ReadMedium