login
Header Space

 
 

use of float or double in kernel module

April 16, 2008 - 4:27am
Submitted by Anonymous on April 16, 2008 - 4:27am.
Linux

Hi

Is it possible to use float or double value in kernel module?

If yes , How to display these values using printk ?

Floating point was only

April 16, 2008 - 5:08am
Anonymous (not verified)

Floating point was only recently (past year?) "enabled". That does not mean anything is supposed to handle floating point right away, and printk is one of these.

From which kernel version

April 16, 2008 - 5:33am
mokhtar (not verified)

From which kernel version float calculation is suported?
Is there some header files that are necessary to use floating calculation ?

Can't precisely remember,

April 27, 2008 - 5:06am
Anonymous (not verified)

Can't precisely remember, I'm getting old! Must be at least two years now. No includes. As always, test it and you know whether it works or not.

But it does work in 2.6.23

April 30, 2008 - 8:05am
Anonymous (not verified)

But it does work in 2.6.23 — I just tried. See http://dev.medozas.de/gitweb.cgi?p=quad_dsp for an example. (WARNING: Violates at least two standard kernel practices.)

float

April 30, 2008 - 1:11am
arethe (not verified)

float a;
printk("a=%d.%d\n",(int)a,(int)(1000*(a-(int)a)));

No floats for you!

April 28, 2008 - 1:56am
Anonymouse (not verified)

The kernel has no need of floats; even where fractions are needed this is easily done in integer arithmetic. Specifically, the FPU will NEVER be used from within the kernel drivers on currently existing x86 family devices. If you want floats, you have to implement arithmetic routines yourself - that is, if no one has made a kernel patch with routines. You really need to put a lot of thought into why you'd want floats in a kernel routine.

There is no legitimate

April 29, 2008 - 10:48am
Anonymous (not verified)

There is no legitimate reason to use floating point within the kernel. You are doing something wrong if you need floats.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
speck-geostationary