ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Общий форум

How to use "sqrt" function without including <math.h>
Послано OverAll 16 апр 2003 02:03
I've got compilation error and I think it's because of including
math.h. Can you advise me something?
Re: How to use "sqrt" function without including <math.h>
Послано MadPsyentist/Sam 16 апр 2003 04:26
> I've got compilation error and I think it's because of including
> math.h. Can you advise me something?
I think your problem shouldn't be including <math.h>

as I quest , it might be this

int a;
double b;
....
b=sqrt(a); //compilation error here

because the parameter pass to sqrt is int , and sqrt in library here has
been overloaded for more than one argument type , but not for int. so
the compiler don't know which one to pick

it can be fix just by casting
int a;
double b;
....
b=sqrt((double)a); // can be compiled now

If you want to view error in more detail than online status page, submit
your solution via e-mail (read FAQ if you don't know how)

anyway if you really can't include <math.h> , implement you own sqrt
(one method is using numerical method)