Calculating .5*x and x/2

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#16 Post by L18L »

my 2 cents
dividing could have code added to test on zero 8)

User avatar
mahaju
Posts: 487
Joined: Mon 11 Oct 2010, 07:11
Location: between the keyboard and the chair

#17 Post by mahaju »

I thought at the machine level such kind of test happened on hardware and not using code, for example, if division by zero is done some kind of overflow flag bit is set in the microprocessor's PSW register

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#18 Post by L18L »

mahaju wrote:I thought at the machine level such kind of test happened on hardware and not using code, for example, if division by zero is done some kind of overflow flag bit is set in the microprocessor's PSW register
Setting this bit might explain the difference?
Dave_G wrote:According to the Intel specs, a MUL takes on average 15 "clocks"
where as a DIV takes on average 16.

User avatar
mahaju
Posts: 487
Joined: Mon 11 Oct 2010, 07:11
Location: between the keyboard and the chair

#19 Post by mahaju »

but it's set only if division by zero is encountered not always
for example, if result of the division exceeds the maximum capacity of the register an overflow bit may be set

User avatar
Dave_G
Posts: 453
Joined: Thu 21 Jul 2011, 13:53

#20 Post by Dave_G »

Note that the CPU does not do a check for dividing (or multiplying) by zero
before it does the actual operation.
Like wise if an overflow occurs.
If it does encounter these conditions then the flag is set.

@mahaju,
The flags register in the x86 range is not called the PSW register, are you
sure you are referring to the same CPU and not some microprocessor such
as the PIC or AVR?

Dave.

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#21 Post by jpeps »

Dave_G wrote: So unless you happen to be doing millions and millions of DIV or MUL operations, you will not notice any advantage of one method over the other.
Wow, I could save hours computing losses on this year's tax return.

User avatar
Dave_G
Posts: 453
Joined: Thu 21 Jul 2011, 13:53

#22 Post by Dave_G »

Whatever rebate you get, I want 10% :D

Bruce B

#23 Post by Bruce B »

jpeps wrote:
Dave_G wrote: So unless you happen to be doing millions and millions of DIV or MUL operations, you will not notice any advantage of one method over the other.
Wow, I could save hours computing losses on this year's tax return.
Don't even file, just have some kin say you moved to somewere in Ireland. Scratch that, tell them you got captured by pirates in Somalia. Scratch that, tell them you are a Somalian pirate.

~

User avatar
Dave_G
Posts: 453
Joined: Thu 21 Jul 2011, 13:53

#24 Post by Dave_G »

@Bruce B,

Do you think that will help?
They will still want you to declare your "takings" and then tax you on that
and last time I checked guns, ammo and eye patches where not tax deductable :D

User avatar
puppyluvr
Posts: 3470
Joined: Sun 06 Jan 2008, 23:14
Location: Chickasha Oklahoma
Contact:

#25 Post by puppyluvr »

:D Hello,
Arrggh, eye matey, but your parrot is a dependent...
Close the Windows, and open your eyes, to a whole new world
I am Lead Dog of the
Puppy Linux Users Group on Facebook
Join us!

Puppy since 2.15CE...

Bruce B

#26 Post by Bruce B »

Dave_G wrote:@Bruce B,

Do you think that will help?
They will still want you to declare your "takings" and then tax you on that
and last time I checked guns, ammo and eye patches where not tax deductable :D
Dave I went years without filing. I just didn't file. I got nervous and went to a CPA. He told me it looks favorable that I filed before they came to me. (I owed them money). I payed them on my own.

Keep in mind I'm not a CPA or an Attorney.

It is my understanding that not filing is not fraud, unless the purpose of not filing is to commit fraud.

Income tax is an estimate. If the estimate is within 20% accurate, it is not fraud I think. Unless an intent to commit fraud can be proved. Although there can be serious financial penalties for the errors.

I've also gone years without filing simply because I didn't owe them money.

Suppose you look at your employer statements and can tell you have some return coming and you don't file.

Suppose you do this for several years. Then one day out of the blue you file. What happens, at least to me, is I got my returns.

The April 15 date is serious if you owe them money because you have to pay penalties which you would not otherwise have had to pay.

I think it is a good idea to file before the 15th if for no other reason than it makes you look normal.

Not filing and tax evasion are simply not one in the same thing. A tax evader can file faithfully and still be an evader. A non evader can not file and still be a non evader.

The basic rule I think is screwing up with your taxes and owing them money can be costly, but not necessarily criminal or even regarded by them as criminal.

Evasion if intentional is criminal.

What I personally would worry about is evasion. To me it is just not worth the risks and lost sleep.

Maybe I'm not all that regular, but I'm not cheating them, so I'm still clean.

I hope this makes sense.

And remember these laws can be very complex, so by all means consider the source, I am a regular guy and not an attorney or accountant.

~

User avatar
Dave_G
Posts: 453
Joined: Thu 21 Jul 2011, 13:53

#27 Post by Dave_G »

I'm not too clued up on the tax laws, so it's always safer to file.

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#28 Post by technosaurus »

so this is why programming is in the off topic area ;)

I would bet that .5*x == x/2 now that gcc uses gmp, mpfr etc...
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#29 Post by jpeps »

technosaurus wrote:so this is why programming is in the off topic area ;)

I would bet that .5*x == x/2 now that gcc uses gmp, mpfr etc...
What's that have to do with filing taxes?

User avatar
Dave_G
Posts: 453
Joined: Thu 21 Jul 2011, 13:53

#30 Post by Dave_G »

jpeps wrote:
What's that have to do with filing taxes?
Quite a lot actually, get those mathematical terms wrong and you will very
soon hear from the tax man. :D

I have to agree with technosaurus, not only is gcc pretty good at optimizing code
but the newer CPUs are pretty efficient too when it comes to optimizing code,
unlike their ancestors.

In the C code listed many posts ago, the printf will take much much longer to execute then any simple multiply or divide function.

Dave.

Post Reply