The Daily Dose

laugh every day with cartoons jokes and humor
  • Home
  • About
    • Press
      • Press Release – Announcing Laughzilla the Third ebook
      • Press Release – The Daily Dose Kicks Off Its 16th Year with New Books and More Irreverent Laughter
      • Press Release – Themes Memes and Laser Beams Now Available in Paperback
      • Press Release – Announcing Themes Memes and Laser Beams
      • In The News
    • Privacy
  • Archive
  • Books
  • Shop
  • Collections
    • Galleries
      • Gallery
      • Captions
      • Flash Cartoons & Greeting Cards
        • Laughzilla’s Oska Flash Animation Cartoon Greeting Cards
        • Oska Cupid Love Humor
    • #OccupyWallStreet
    • cats
    • China
    • Food
      • Hors d’oeuvres
        • Ball of Cream Cheese
      • Entrees / Main Courses
        • Meatballs with Baked Beans and Celery
    • Gadaffy
    • Google
  • Links
  • Video
  • Submit a joke
DeviantART Facebook Twitter Flickr pinterest YouTube RSS

Subscribe for Free Laughs!


 

Latest Comics

  • This Memorial Day, Trump Meme Coin Congratulates Profit Takers
  • 25 Years of The Daily Dose
  • The Best Cartoons
  • Bitcoin sings “Fly Me To The Moon”
  • 22 years of The Daily Dose

Comic Archive

Occupy March Madness Math

Daily Dose News Roundup

  • OpenAI adopts C2PA standard and Google’s SynthID to make AI-generated images easier to identify
  • OpenClaw creator’s $1.3 million monthly OpenAI bill reveals the real cost of autonomous AI coding at scale
  • Apple’s Siri app in iOS 27 will auto-delete your chats. It may also launch as a beta, again.
  • Faraday Future raised $25 million for its robotics pivot. The fine print tells a different story.
  • Anthropic and the Gates Foundation are betting $200 million that AI can do more than make money

Quotable

"U.S. Secretary of State Hillary Clinton said publicly that the United States would not intervene in Syria, because the American Congress views second generation Syrian dictator Bashar Assad as a reformer. Is that because his live ammunition is reformed, or because his state sponsorship of terrorism and repressive abuse of human rights and free speech are so humanitarian?" ~ Yasha Harari

Fresh Baked Goods

Get The Daily Dose's ebook: Laughzilla the Third - A Funny Stuff Collection of 101 Cartoons from TheDailyDose. Click here to get the e-book on Amazon kdp. Laughzilla the Third (2012) The Third Volume in the Funny Stuff Cartoon Book Collection Available Now.

Click here for the Paperback edition


Support independent publishing: Buy The Daily Dose's book: Themes Memes and Laser Beams - A Funny Stuff Collection of 101 Cartoons by Laughzilla from TheDailyDose. Click here to get the book on Amazon. Themes Memes and Laser Beams - The Second Volume in the Funny Stuff Cartoon Book Collection.

Click Here to get the book in Paperback While Available on Amazon

Themes Memes and Laser Beams - 101 Cartoons by Laughzilla. Get the e-book on Lulu.

Click Here to get The Daily Dose Cartoon ebook on amazon kindle

Funny Stuff :
The First Cartoon Book
from The Daily Dose.
Available on Lulu.

a couple of laughzillas on a blue diamond background

June in Africa: All the tech news you shouldn’t miss from the past month

Jun30
by Sindy Cator on June 30, 2014 at 12:29 pm
Posted In: Around the Web, Insider, Roundups

Cape Town
Last month was a typically busy one for the African tech scene, with notable activities from big international players and a number of new launches, acquisitions and expansions of real note. See below for any news you may have missed. Moves by big players PayPal launched in ten new markets, making Nigeria, Cameroon, Ivory Coast and Zimbabwe the first four African countries to have access to the platform. Services are now live, allowing customers to register for a PayPal account and make payments to millions of sites worldwide. Uber launched its low-cost UberX service in Cape Town, to run alongside…

This story continues at The Next Web

└ Tags: Africa, news, syndicated
a couple of laughzillas on a blue diamond background

Samsung’s new low-end smartphones offer Android 4.4 and its redesigned TouchWiz skin

Jun30
by Sindy Cator on June 30, 2014 at 12:12 pm
Posted In: Around the Web, Gadgets, Product Launches

A logo of Samsung Electronics is seen on
It’s almost impossible to keep up with Samsung’s ever-expanding smartphone portfolio. Unfortunately, the problem only deepened today after the company unveiled four new low-end smartphones with equally forgettable names and spec-sheets. First out the blocks is the Galaxy Core II, which features a 4.5-inch WVGA display, quad-core 1.2GHz processor and 2,000mAh battery. Sliding underneath is the slightly less powerful Galaxy Ace 4, which offers a smaller 4-inch panel, dual-core 1.2GHz processor, 1,800 mAh battery and LTE connectivity. A 3G variant is also available with a 1GHz processor and 1,500 mAh battery. Samsung Galaxy Core II Dropping even further into budget-territory…

This story continues at The Next Web

└ Tags: news, syndicated
a couple of laughzillas on a blue diamond background

June in Eastern Europe: All the tech news you shouldn’t miss from the past month

Jun30
by Sindy Cator on June 30, 2014 at 11:56 am
Posted In: Around the Web, Insider, Roundups

eastern-europe
The first month of summer has shown clearly that entrepreneurs and tech industry players are not attracted by blue seas and white sands but prefer to work hard, bringing more and more news from Eastern Europe for this round-up. Check the headlines and make sure that you’ve not missed anything of importance. If you think that something is missing, or would like to draw our attention to an important story, feel free to ping the author in Twitter (@shlema) or by e-mail at shlema@gmail.com. Startups, funds and accelerators Startup Wise Guys has partnered with UK-based Notion Capital for its fall ’14…

This story continues at The Next Web

└ Tags: europe, syndicated
a couple of laughzillas on a blue diamond background

June in Eastern Europe: All the tech news you shouldn’t miss from the past month

Jun30
by Sindy Cator on June 30, 2014 at 11:56 am
Posted In: Around the Web, Insider, Roundups

eastern-europe
The first month of summer has shown clearly that entrepreneurs and tech industry players are not attracted by blue seas and white sands but prefer to work hard, bringing more and more news from Eastern Europe for this round-up. Check the headlines and make sure that you’ve not missed anything of importance. If you think that something is missing, or would like to draw our attention to an important story, feel free to ping the author in Twitter (@shlema) or by e-mail at shlema@gmail.com. Startups, funds and accelerators Startup Wise Guys has partnered with UK-based Notion Capital for its fall ’14…

This story continues at The Next Web

└ Tags: europe, syndicated
a couple of laughzillas on a blue diamond background

Converting Numbers to Words Part III

Jun30
by Sindy Cator on June 30, 2014 at 11:30 am
Posted In: Around the Web, VBA

See Converting Numbers to Words Part II

My tests work from 0-99. The next test will test numbers between 100-199.

Sub TEST_OneHundred()

    Debug.Assert NumbersToWords(100) = "one hundred"
    Debug.Assert NumbersToWords(110) = "one hundred ten"
    Debug.Assert NumbersToWords(119) = "one hundred nineteen"
    Debug.Assert NumbersToWords(120) = "one hundred twenty"
    Debug.Assert NumbersToWords(121) = "one hundred twenty-one"
    Debug.Assert NumbersToWords(150) = "one hundred fifty"
    Debug.Assert NumbersToWords(188) = "one hundred eighty-eight"
    Debug.Assert NumbersToWords(199) = "one hundred ninety-nine"

End Sub

A haphazard selection of numbers including the edge cases.

Function NumbersToWords(ByVal dNumbers As Double) As String
   
    Dim vaSingles As Variant
    Dim vaTens As Variant
    Dim sReturn As String
   
    vaSingles = Split("zero,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen", ",")
    vaTens = Split("NA,NA,twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety", ",")
       
    If dNumbers >= 100 Then
        sReturn = "one hundred"
        If dNumbers Mod 100 <> 0 Then
            If dNumbers – 100 > 19 Then
                sReturn = sReturn & Space(1) & vaTens((dNumbers – 100) \ 10)
                If (dNumbers – 100) Mod 10 <> 0 Then
                    sReturn = sReturn & "-" & vaSingles((dNumbers – 100) – (((dNumbers – 100) \ 10) * 10))
                End If
            Else
                sReturn = sReturn & Space(1) & vaSingles(dNumbers – 100)
            End If
        End If
       
    ElseIf dNumbers > 19 Then
        sReturn = vaTens(dNumbers \ 10)
        If dNumbers Mod 10 <> 0 Then
            sReturn = sReturn & "-" & vaSingles(dNumbers – ((dNumbers \ 10) * 10))
        End If
    Else
        sReturn = vaSingles(dNumbers)
    End If
   
   
    NumbersToWords = Trim$(sReturn)
   
End Function

And all tests pass. Back in the first post of this series I said that I hoped it would be obvious when I need to refactor. Well if this isn’t a frying pan to the face, I don’t know what is. Way too much repetition, for one. I need to introduce a “remainder” variable, so that once I process the hundred part, I can send the remainder to process the tens, and the remainder from that to the less than 19 part.

Function NumbersToWords(ByVal dNumbers As Double) As String

    Dim vaSingles As Variant
    Dim vaTens As Variant
    Dim sReturn As String
    Dim dRemainder As Double

    vaSingles = Split("zero,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen", ",")
    vaTens = Split("zero,zero,twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety", ",")

    dRemainder = dNumbers

    If dRemainder >= 100 Then
        sReturn = "one hundred" & Space(1)
        dRemainder = dRemainder – (dRemainder \ 100) * 100
    End If

    If dRemainder > 19 Then
        sReturn = sReturn & vaTens(dRemainder \ 10)
        dRemainder = dRemainder – (dRemainder \ 10) * 10
    End If

    If dRemainder > 0 Then
        If Right(sReturn, 1) = "y" Then
            sReturn = sReturn & "-"
        End If

        sReturn = sReturn & vaSingles(dRemainder)
    End If

    NumbersToWords = Trim$(sReturn)

End Function

That looks much better, but it doesn’t pass the zero test. I don’t like special cases, but zero might just be one, so I’m going to force it. My conditional on whether to include a hyphen checks to see if the answer so far ends in “y”. That seems a little hokey, but it works. I could test for mod10 and set a Boolean variable in the If block above, but I’m not sure what I gain, so there it stays.

Refactoring in this way also makes the next bit of testing code painfully obvious. I’m hardcoding “one hundred”, but with vaSingles sitting right there, I don’t know why I can’t go above 199 pretty easily. So I’ll write that next test.

Sub TEST_Hundreds()

    Debug.Assert NumbersToWords(200) = "two hundred"
    Debug.Assert NumbersToWords(310) = "three hundred ten"
    Debug.Assert NumbersToWords(419) = "four hundred nineteen"
    Debug.Assert NumbersToWords(520) = "five hundred twenty"
    Debug.Assert NumbersToWords(621) = "six hundred twenty-one"
    Debug.Assert NumbersToWords(750) = "seven hundred fifty"
    Debug.Assert NumbersToWords(888) = "eight hundred eighty-eight"
    Debug.Assert NumbersToWords(999) = "nine hundred ninety-nine"

End Sub

Instead of hardcoding “one hundred”, I’ll pull the property number from vaSingles. This also shows my brute force zero fix.

Function NumbersToWords(ByVal dNumbers As Double) As String

    Dim vaSingles As Variant
    Dim vaTens As Variant
    Dim sReturn As String
    Dim dRemainder As Double

    vaSingles = Split("zero,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen", ",")
    vaTens = Split("zero,zero,twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety", ",")

    If dNumbers = 0 Then
        sReturn = "zero"
    Else

        dRemainder = dNumbers
   
        If dRemainder >= 100 Then
            sReturn = sReturn & vaSingles(dRemainder \ 100) & " hundred "
            dRemainder = dRemainder – (dRemainder \ 100) * 100
        End If
   
        If dRemainder > 19 Then
            sReturn = sReturn & vaTens(dRemainder \ 10)
            dRemainder = dRemainder – (dRemainder \ 10) * 10
        End If
   
        If dRemainder > 0 Then
            If Right(sReturn, 1) = "y" Then
                sReturn = sReturn & "-"
            End If
   
            sReturn = sReturn & vaSingles(dRemainder)
        End If
    End If

    NumbersToWords = Trim$(sReturn)

End Function

All tests pass. And the code doesn’t look too bad. Only infinity numbers left to test. Here’s what my main testing procedure looks like now, as if you couldn’t guess.

Sub TEST_All()

    TEST_Singles
    TEST_Tens
    TEST_OneHundred
    TEST_Hundreds

    Debug.Print "tests passed"

End Sub

└ Tags: syndicated
  • Page 13,414 of 14,644
  • « First
  • «
  • 13,412
  • 13,413
  • 13,414
  • 13,415
  • 13,416
  • »
  • Last »
The Daily Dose, The Daily Dose © 1996 - Present. All Rights Reserved.
  • Home
  • About
  • Archive
  • Books
  • Collections
  • Links
  • Shop
  • Submit a joke
  • Video
  • Privacy Policy