Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 538733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:03:45+00:00 2026-05-13T10:03:45+00:00

I am learning Haskell. I have created function which returns multiplication table up to

  • 0

I am learning Haskell. I have created function which returns multiplication table up to ‘n’ in base ‘b’. Numbers are padded to ‘w’ digits. As the last step, I want to compute ‘w’ automatically. Why does this not compile?

-- Number of digits needed for the multiplication table n*n in base 'base'
nOfDg :: Int -> Int-> Int 
nOfDg n base = 1 + floor ( logBase base (n*n)) 

error:

No instance for (Floating Int)
     arising from a use of `logBase' at C:\haskel\dgnum.hs:4:24-38
   Possible fix: add an instance declaration for (Floating Int)
   In the first argument of `floor', namely `(logBase b (n * n))'
   In the second argument of `(+)', namely `floor (logBase b (n * n))'
   In the expression: 1 + floor (logBase b (n * n))
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T10:03:45+00:00Added an answer on May 13, 2026 at 10:03 am

    logBase takes two parameters which implement the floating typeclass. You’ll need to call fromIntegral on the parameters before passing them to logBase. This compiled for me with 6.10.3:

    nOfDg :: Int -> Int-> Int
    nOfDg n base = 1 + floor ( logBase (fromIntegral base) (fromIntegral (n*n)))
    

    You have to remember that Haskell is very strongly typed, so you can’t just assume that the Int parameters supplied to your function will automatically be coerced to the floating numbers that log functions generally take.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 506k
  • Answers 506k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer So the solution I'll use is that I load a… May 16, 2026 at 3:36 pm
  • Editorial Team
    Editorial Team added an answer NServiceBus use msmq as its main transport but does not… May 16, 2026 at 3:36 pm
  • Editorial Team
    Editorial Team added an answer The relevant RFC is 2616, specifically the sections on status… May 16, 2026 at 3:36 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Suppose I am defining a Haskell function f (either pure or an action) and
I'm interested in learning Haskell on my own time (not through a course), but
I started learning haskell yesterday and I got stuck on a problem. After a
I'm learning Haskell in the hope that it will help me get closer to
As part of learning Haskell, I am trying to implement my own version of
I'm trying to broaden my mind by learning Haskell. My self-inflicted homework was to
Ok, referring back to my previous question, I am still working on learning haskell
I'm playing around with beginner Haskell, and I wanted to write an average function.
I'm just learning Haskell, so sorry if my question is stupid. I'm reading learnyouahaskell.com
Still learning JSP Web Applications here. I have been doing this for a while

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.