473,379 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

ceil() and log10() - undefined?

ptn
Hi everyone,

I was messing around with math.h and I got this error:

"""
/tmp/ccefZYYN.o: In function `digcount':
itos.c:(.text+0x103): undefined reference to `log10'
itos.c:(.text+0x111): undefined reference to `ceil'
collect2: ld returned 1 exit status

shell returned 1
"""

It can't be that log10() and ceil() aren't defined, because math.h
takes care of that. I admit that I have no idea what .text+0x111/.text
+0x103 means

The complete code is here:

# include <stdio.h>
# include <malloc.h>
# include <math.h>

int digcount(int num); // counts the digits of <num>

main()
// transform a number to a string
{
int num, fact, dig, digits, i;
char *s;

scanf("%d", &num);
digits = digcount(num);
s = (char *) malloc((digits + 1) * sizeof(char)); // assign just
enough space
s += (digits - 1); // go to the last address of the memory space
assigned
*s-- = '\0'; // mark the end of the string
for (i = 0; i < digits; i++) {
dig = num % 10;
num /= 10;
*s-- = '0' + dig; // store digit by digit
}
printf("\"%s\"\n", ++s); // after the for, s is pointing to the
addres before the start of the string
}

int digcount(int num)
/* N = trunc(log(x), 0) + 1, where N is the number of digits of x */
{
double ans;

ans = log10(num);
ans = ceil(ans);
return (int) ans;
}

Any ideas are welcome.
(I'm using Vim + gcc under Ubuntu Feisty Fawn)

Thanks,

Pablo Torres Navarrete

Oct 3 '07 #1
1 4885
On Oct 3, 8:55 am, ptn <tn.pa...@gmail.comwrote:
Hi everyone,

I was messing around with math.h and I got this error:

"""
/tmp/ccefZYYN.o: In function `digcount':
itos.c:(.text+0x103): undefined reference to `log10'
itos.c:(.text+0x111): undefined reference to `ceil'
collect2: ld returned 1 exit status

shell returned 1
"""

It can't be that log10() and ceil() aren't defined, because math.h
takes care of that. I admit that I have no idea what .text+0x111/.text
+0x103 means

The complete code is here:

# include <stdio.h>
# include <malloc.h>
# include <math.h>

int digcount(int num); // counts the digits of <num>

main()
// transform a number to a string
{
int num, fact, dig, digits, i;
char *s;

scanf("%d", &num);
digits = digcount(num);
s = (char *) malloc((digits + 1) * sizeof(char)); // assign just
enough space
s += (digits - 1); // go to the last address of the memory space
assigned
*s-- = '\0'; // mark the end of the string
for (i = 0; i < digits; i++) {
dig = num % 10;
num /= 10;
*s-- = '0' + dig; // store digit by digit
}
printf("\"%s\"\n", ++s); // after the for, s is pointing to the
addres before the start of the string

}

int digcount(int num)
/* N = trunc(log(x), 0) + 1, where N is the number of digits of x */
{
double ans;
Too difficult question for me
ans = log10(num);
ans = ceil(ans);
return (int) ans;

}

Any ideas are welcome.
(I'm using Vim + gcc under Ubuntu Feisty Fawn)

Thanks,

Pablo Torres Navarrete

Oct 3 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jack | last post by:
I have a problem that I can't seem to solve. I have checked the round, ceil and floor functions and they don't seem to do what I want. I have an entry like this <?php $tax = .065; $ad2day =...
6
by: RobG | last post by:
I am writing a script to move an absolutely positioned element on a page by a factor using style.top & style.left. The amount to move by is always some fraction, so I was tossing up between...
0
by: BuddyWork | last post by:
Hello, Here is an update. There is no differences with the function System.Math.Log10 under any operating system. The problem is with the casting of the datatype double and value Infinite...
3
by: BernsteinVsTheDb | last post by:
Hello all, I have a table that contains 100+ rows. I'm trying to run a query that looks like this: SELECT ..., log10(...) as Rank FROM Table and the resultset contains only the first row of...
20
by: mikael.liljeroth | last post by:
Why do I get NO as result from this ?? double du = (double)3.1415; du = ceil(du); if(du == (double)4) printf("YES\n"); else printf("NO\n");
2
by: RB Smissaert | last post by:
Just starting with C++ in MS VC6++. Why does this: return (log10(70)); produce 1 and not 1.845098 ? I can see it is giving me the rounded integer number, but why? The return type of the...
14
by: yansong1990 | last post by:
Uhm..it's my 1st time using this fuction...could someone provide anexample for me please? thanks
13
by: ptn | last post by:
Hi everyone, I was messing around with math.h and I got this error: """ /tmp/ccefZYYN.o: In function `digcount': itos.c:(.text+0x103): undefined reference to `log10' itos.c:(.text+0x111):...
7
by: MrIncognito | last post by:
Am I using this correctly? This line of code is supposed to find the number of bytes in one line of a 16 color bitmap, but it doesn't seem to work most of the time. long linesize = ceil((double)...
7
by: mingke | last post by:
I've learned that we can round up and down a float number by using Ceil and floor function. But, is this function still able to work if I the number I want to round up (or down) is zero? I have...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.