I haven't had to use a float or double yet. Does this come up in kernel space development?
Thanks!
How often do you find yourself using floating point data typ
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: How often do you find yourself using floating point data typ
I've used it for color depth conversion (i.e. 24bit -> 16bit) but that was a while ago. It was more for my bootloader, though, and I don't really use it anymore. At the moment I can't think of anything kernel-specific (i.e. not something more suited to a driver or user-space library) that requires a float, though.
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Re: How often do you find yourself using floating point data typ
I just about never use floats unless it's part of some programming course in school... (Java's best friend is floats apparently)
The only real time I've used floats in any program I made as a hobby was for a little tool to calculate from my clock out stubs how much my check should be.. I would have been perfectly happy hacking around a fixed point though..
The only real time I've used floats in any program I made as a hobby was for a little tool to calculate from my clock out stubs how much my check should be.. I would have been perfectly happy hacking around a fixed point though..
Re: How often do you find yourself using floating point data typ
I have float/double/long double and SSE support built-in to my kernel (if supported). I primarily use doubles and long doubles.
I use them quite often though, I perform a lot of averaging and want to make sure I maintain precision. I also have coded in double/long double printing support into my printf. There's not a lot that needs to be set up to support FPU ops, see the FPU wiki article and just make sure you use FSAVE and such when you use it in a multi-tasking environment.
I use them quite often though, I perform a lot of averaging and want to make sure I maintain precision. I also have coded in double/long double printing support into my printf. There's not a lot that needs to be set up to support FPU ops, see the FPU wiki article and just make sure you use FSAVE and such when you use it in a multi-tasking environment.
Website: https://joscor.com
Re: How often do you find yourself using floating point data typ
The only time I used floats(libgmp) was in a high-precision PI-calculation-programm.
I never used the standard floats (like in C).
I never used the standard floats (like in C).
- mathematician
- Member
- Posts: 437
- Joined: Fri Dec 15, 2006 5:26 pm
- Location: Church Stretton Uk
Re: How often do you find yourself using floating point data typ
Personally I seldom use a float no matter what the type of development. Unless you are writing a program which makes explicit use of mathematics (or at least arithmetic), I wouldn't worry about it too much.tkahn6 wrote:I haven't had to use a float or double yet. Does this come up in kernel space development?
Thanks!
The continuous image of a connected set is connected.
Re: How often do you find yourself using floating point data typ
Hi,
I never really used signed integers either. Almost everything uses unsigned integers, because almost everything is table indexes or addresses or bitfields.
FPU would have made one part of my boot code easier (GTF calculations for video modes), and I've been using floats/doubles a lot lately for bitmap image processing, but a micro-kernel doesn't do anything like that.
@01000101: Not sure why you'd need floats/doubles for averaging (or what you use averaging for). If the data is integers (which IMHO is likely), then you can keep track of the sum and the count with integers without any precision loss, and find the average with one division (where an integer answer can be accurate to within 0.5 without using fixed point).
Note: When I want "round to nearest" integer division, I do something like:
Cheers,
Brendan
I've never used floating point in any kernel, partly because my kernels are designed to work on CPUs that don't have FPU, and partly because I don't save FPU/MMX/SSE state during task switches unless it's necessary (where using FPU in the kernel makes this necessary, and therefore increases the cost of task switches). I can't think of anything that I would have wanted to use FPU for either - the closest would have been calculating timer counts (e.g. "PIT_count = (3579545 / 3) / desired_frequency") but this has to be an integer anyway, so there's no reason to use float/double for extra accuracy.tkahn6 wrote:I haven't had to use a float or double yet. Does this come up in kernel space development?
I never really used signed integers either. Almost everything uses unsigned integers, because almost everything is table indexes or addresses or bitfields.
FPU would have made one part of my boot code easier (GTF calculations for video modes), and I've been using floats/doubles a lot lately for bitmap image processing, but a micro-kernel doesn't do anything like that.
@01000101: Not sure why you'd need floats/doubles for averaging (or what you use averaging for). If the data is integers (which IMHO is likely), then you can keep track of the sum and the count with integers without any precision loss, and find the average with one division (where an integer answer can be accurate to within 0.5 without using fixed point).
Note: When I want "round to nearest" integer division, I do something like:
Code: Select all
mov eax, <dividend_low_32bits>
mov edx, <dividend_high_32bits>
mov ecx, <divisor>
div ecx ;eax = quotient, edx = remainder
dec ecx ;ecx = divisor - 1
add edx,edx ;edx = remainder * 2
cmp ecx,edx ;Set carry flag if (remainder * 2) > (divisor - 1)
adc eax,0
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: How often do you find yourself using floating point data typ
Me too. and i think FPU operations not needed in kernel ,if so please tell me whereBrendan wrote:Hi,
I've never used floating point in any kernel, partly because my kernels are designed to work on CPUs that don't have FPU,tkahn6 wrote:I haven't had to use a float or double yet. Does this come up in kernel space development?
CheerS,
a.T.d
Distance doesn't make you any smaller,
but it does make you part of a larger picture.
but it does make you part of a larger picture.
Re: How often do you find yourself using floating point data typ
Important point, here. Saving / restoring FPU state is a costly operation, which can easily be avoided because you don't exactly need floats for kernel-space code AFAICT.Brendan wrote:...I don't save FPU/MMX/SSE state during task switches unless it's necessary (where using FPU in the kernel makes this necessary, and therefore increases the cost of task switches).
Every good solution is obvious once you've found it.