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

Black Friday Occupy Shopping

Daily Dose News Roundup

  • Chinese profits rose 25.7%. The CSI 300 fell 9% and the Star 50 fell 29%
  • 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

Quotable

"If the question is to be or not to be then the answer is to do or not to do." ~ 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

Converting Numbers to Words Part V

Jul02
by Sindy Cator on July 2, 2014 at 11:30 am
Posted In: Around the Web, VBA

See Converting Numbers to Words Part IV

No need to bite this one off in small chunks. Just need to make sure the triplets processing works at the next level.

Sub TEST_Millions()
   
    Debug.Assert NumbersToWords(1000000) = "one million"
    Debug.Assert NumbersToWords(1000001) = "one million one"
    Debug.Assert NumbersToWords(20000000) = "twenty million"
    Debug.Assert NumbersToWords(55555000) = "fifty-five million five hundred fifty-five thousand"
    Debug.Assert NumbersToWords(999999999) = "nine hundred ninety-nine million nine hundred ninety-nine thousand nine hundred ninety-nine"
   
End Sub

I’m just going to add a new If block for millions that looks a lot like the thousands If block. Of course I’ll be using exponents so I don’t have to type all those zeros.

Function NumbersToWords(ByVal dNumbers As Double) As String
   
    Dim sReturn As String
    Dim dRemainder As Double
   
    If dNumbers = 0 Then
        sReturn = "zero"
    Else
       
        dRemainder = dNumbers
       
        If dRemainder >= 10 ^ 6 Then
            sReturn = ProcessTriplet(dRemainder \ 10 ^ 6, "million")
            dRemainder = dRemainder – ((dRemainder \ 10 ^ 6) * 10 ^ 6)
        End If
       
        If dRemainder >= 1000 Then
            sReturn = sReturn & Space(1) & ProcessTriplet(dRemainder \ 1000, "thousand")
            dRemainder = dRemainder – ((dRemainder \ 1000) * 1000)
        End If
       
        If dRemainder > 0 Then
            sReturn = sReturn & Space(1) & ProcessTriplet(dRemainder)
        End If
       
    End If
   
    NumbersToWords = Trim$(sReturn)
   
End Function

All tests passed. The rest should be easy. I’m going to go a little sparse on the next tests.

Sub TEST_More()
   
    Debug.Assert NumbersToWords(1 * 10 ^ 9) = "one billion"
    Debug.Assert NumbersToWords(1000000001) = "one billion one"
    Debug.Assert NumbersToWords(999999999999999#) = "nine hundred ninety-nine trillion nine hundred ninety-nine billion nine hundred ninety-nine million nine hundred ninety-nine thousand nine hundred ninety-nine"
   
End Sub

I could create a new If block for each triplet, but I already know I’ll be refactoring, so what’s the point. I need to loop through however many triplets are there and process them.

Function NumbersToWords(ByVal dNumbers As Double) As String
   
    Dim sReturn As String
    Dim dRemainder As Double
    Dim vaTriplets As Variant
    Dim i As Long
   
    vaTriplets = Split(",,,thousand,,,million,,,billion,,,trillion", ",")
   
    If dNumbers = 0 Then
        sReturn = "zero"
    Else
       
        dRemainder = dNumbers
       
        For i = 12 To 0 Step -3
            If dRemainder >= 10 ^ i Then
                sReturn = sReturn & Space(1) & ProcessTriplet(dRemainder \ 10 ^ i, vaTriplets(i))
                dRemainder = dRemainder – ((dRemainder \ 10 ^ i) * 10 ^ i)
            End If
        Next i
       
    End If
   
    NumbersToWords = Trim$(sReturn)
   
End Function

Error: Overflow. I originally passed in a Double so I could do decimals, but never did the decimals. Anyway, it’s the integer division operator (\) that’s causing the problem. When you use a floating point number, like a Double, in an integer division expression, VBA casts it as a Long first. So anything more than 2.4 billion won’t work. Fortunately, MS has a fix.

Function NumbersToWords(ByVal dNumbers As Double) As String
   
    Dim sReturn As String
    Dim dRemainder As Double
    Dim vaTriplets As Variant
    Dim i As Long
    Dim lFixed As Long
   
    vaTriplets = Split(",,,thousand,,,million,,,billion,,,trillion", ",")
   
    If dNumbers = 0 Then
        sReturn = "zero"
    Else
       
        dRemainder = dNumbers
       
        For i = 12 To 0 Step -3
            If dRemainder >= 10 ^ i Then
                lFixed = Fix(Int(dRemainder + 0.5) / 10 ^ i)
                sReturn = sReturn & Space(1) & ProcessTriplet(lFixed, vaTriplets(i))
                dRemainder = dRemainder – (lFixed * 10 ^ i)
            End If
        Next i
       
    End If
   
    NumbersToWords = Trim$(sReturn)
   
End Function

All tests passed. And that’s it. I could add decimals, I suppose. Or even larger numbers.

The test-first methodology was pretty enjoyable, I have to say. This isn’t especially complicated code, but biting it off in small chunks made things flow nicely.

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

Haste for iPhone is like QuizUp meets Boggle

Jul02
by Sindy Cator on July 2, 2014 at 10:56 am
Posted In: Apps, Around the Web, Insider, Product Reviews

Haset
With games such as QuizUp seemingly killing it in the popularity stakes, it’s no surprise that we now see a steady slew of similar-ish games hit the market. Haste is the latest fast-paced, friends vs. friends-style game to hit the App Store, and it certainly lends more than a nod to the aforementioned QuizUp, “they were quite an inspiration for us,” explains co-creator Lockie Potts. But Haste is different – it’s a word game built around real-time, live multiplayer action. It takes the age-old word-search puzzle game ethos, or more specifically Boggle, and gives it the 2014 treatment. How it…

This story continues at The Next Web

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

‘India’s Amazon’ Flipkart teams up with Karbonn to launch Android smartphones from $45

Jul02
by Sindy Cator on July 2, 2014 at 9:58 am
Posted In: Around the Web, flipkart, Gadgets, India, karbonn, Product Launches

A50s White Phone Picture(1)
Indian e-commerce juggernaut Flipkart is getting busy in the mobile device market. Today, it announced that it has teamed up with phone manufacturer Karbonn to launch a series of what it calls “budget smartphones” ranging from a mere Rs 2,699 ($45) to Rs 4,499 ($75). The smartphones are all dual-SIM and run on Android Jelly Bean or KitKat. Last week, the company stepped into the tablet space with the launch of its own Rs 9,999 ($166) seven-inch tablet, branded under Digiflip Pro. There are two 2G phones in the series — the Karbonn Smart A50S and A52+, which both have screen sizes of 3.5…

This story continues at The Next Web

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

Facebook’s new type of ad in India lets users place a ‘missed call’ for more information

Jul02
by Sindy Cator on July 2, 2014 at 9:07 am
Posted In: Around the Web, India, Product Updates

INDIA-INTERNET-FACEBOOK
Facebook faces several challenges in emerging markets. The company has to find ways for people to access its platform by maneuvering around limitations which include a widespread use of feature phones, users who want to save on communication costs, and the slow internet speed in certain countries. To still appeal to advertisers who want to target customers in emerging markets such as Brazil, Indonesia, India, Turkey and South Africa, Facebook has had to come up with ad products that are better suited to the needs of users and advertisers in such countries. One of these experiments is currently taking place in…

This story continues at The Next Web

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

Facebook’s new type of ad in India lets users place a ‘missed call’ for more information

Jul02
by Sindy Cator on July 2, 2014 at 9:07 am
Posted In: Around the Web, India, Product Updates

INDIA-INTERNET-FACEBOOK
Facebook faces several challenges in emerging markets. The company has to find ways for people to access its platform by maneuvering around limitations which include a widespread use of feature phones, users who want to save on communication costs, and the slow internet speed in certain countries. To still appeal to advertisers who want to target customers in emerging markets such as Brazil, Indonesia, India, Turkey and South Africa, Facebook has had to come up with ad products that are better suited to the needs of users and advertisers in such countries. One of these experiments is currently taking place in…

This story continues at The Next Web

└ Tags: facebook, news, syndicated
  • Page 13,413 of 14,665
  • « First
  • «
  • 13,411
  • 13,412
  • 13,413
  • 13,414
  • 13,415
  • »
  • 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