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

Obama Romney Driving Off A Cliff

Daily Dose News Roundup

  • Novo Nordisk Foundation to build $62M quantum chip plant in Copenhagen
  • The US Army used a laser weapon on American soil, then bought it
  • The European Commission is looking at Oracle’s licensing, two months after settling with SAP
  • The FTC says Amazon charged advertisers the wrong price 80% of the time
  • Europe has ordered a €388M AI supercomputer from its own state-owned champion

Quotable

"The Year is passed! Long live the New Year!" ~ 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 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
a couple of laughzillas on a blue diamond background

Facebook posts, comments and likes related to the World Cup have already topped 1 billion

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

FBL-BRAZIL-ARGENTINA-SUPERCLASSIC
The FIFA World Cup is a sure-fire way to get people talking. Goals, dives, injuries and unexpected results; all of this has people shouting at their TV and, increasingly, using social media such as Facebook and Twitter to express their volatile emotions. Today, Facebook announced that total interactions related to the tournament have passed the 1 billion mark. The mammoth figure includes World Cup-related posts, comments and likes between June 12 and 29. “Facebook generally sees a large amount of conversation around sporting events, but the World Cup has proven to be a unique moment,” the company said. “Facebook’s data…

This story continues at The Next Web

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

Facebook posts, comments and likes related to the World Cup have already topped 1 billion

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

FBL-BRAZIL-ARGENTINA-SUPERCLASSIC
The FIFA World Cup is a sure-fire way to get people talking. Goals, dives, injuries and unexpected results; all of this has people shouting at their TV and, increasingly, using social media such as Facebook and Twitter to express their volatile emotions. Today, Facebook announced that total interactions related to the tournament have passed the 1 billion mark. The mammoth figure includes World Cup-related posts, comments and likes between June 12 and 29. “Facebook generally sees a large amount of conversation around sporting events, but the World Cup has proven to be a unique moment,” the company said. “Facebook’s data…

This story continues at The Next Web

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

Blackphone, the privacy-focused Android smartphone, begins shipping to pre-order customers

Jun30
by Sindy Cator on June 30, 2014 at 10:58 am
Posted In: Around the Web, Gadgets, Insider

blackphone
Blackphone, the privacy-focused Android smartphone unveiled back in January, is finally a real product. Collaborators Silent Circle, an encrypted communications firm and Geeksphone, a Spanish smartphone maker today announced that the first handsets have begun shopping to pre-orders customers. It’s been a long time coming. Pre-orders opened in February, during Mobile World Congress in Barcelona, and the first handsets were expected to ship in April. The handset itself sports a quad-core 2 GHz processor, 2GB of RAM, 16GB of onboard storage and support for LTE networks. The components aren’t bleeding-edge, but bundled with the $629 asking price is a suite…

This story continues at The Next Web

└ Tags: news, syndicated
  • Page 13,436 of 14,665
  • « First
  • «
  • 13,434
  • 13,435
  • 13,436
  • 13,437
  • 13,438
  • »
  • 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