Help coderanch get a
new server
by contributing to the fundraiser

Dylan Margoczi

Ranch Hand
+ Follow
since Jul 12, 2007
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dylan Margoczi

thanks. I'll give that a try.
14 years ago
line 12 in the code bdNumber should be bdTotal.
14 years ago
thanks for the input guys.
the problem is it can be any number not just an integer.

I've had a look at the BigDecimal class but it doesn't seem to solve my problem but make it worse.
here is basically how I've done my code. It's not a practical example but shows my problem.

printout :
ratio = 0.00215053763440860215
new total = 0.99999999999999999975

the new total should be the same as the original total. ie 1.

I can see where I am going wrong I just don't know how to fix this?
14 years ago
Hi guys, i got a simple problem of losing precision when trying to use a ratio against total number values.

first I'll get a ratio simply by dividing a number by a total value, then i will use that ratio to get the same percentage of another total.
So if I have 2 totals, say 100 and 200 and the number I want from my first total is 20. I will divide 20 by 100 to get my ratio, then times my second total by the ratio to get 40.

The problem lies in the method I got that uses this. all the numbers are double and I think the problem is that a double type isn't large enough to use for a ratio and loses precision.

For example if I use 465 and 930 as my totals and the number i want from my first total is 125. (if i do the same calculation) :
My ratio is 0.26881720430107525
and the amount I get from using this ratio against the second total is 249.99999999999997 when I should get 250.

I hope I have explained this well enough...
Is there a sure way to overcome this problem?

thanks in advance.
14 years ago
Thanks a lot for the advice Peter.

I'll take the external program route as I highly doubt I'll need to do anything externally again.

thanks again.
16 years ago
Good morning Ladies and gents.

I was just wondering if it's better if possible to run an external ".exe" program (maybe written in c) rather than using JNI.

I've had a look at JNI and it looks like it could be alot easier to simply just run an exe.

I need this for getting the hard drive serial number (Which I know can't be done in java).

Any advice or thoughts on this topic would be greatly appreciated.

thanks in advance.
16 years ago
It comes up as "Unicode" in EmEditor. but when I try read it using "Unicode" in the program it still doesn't come out right.

I need to convert it to characters in order to work with it.
Thanks Ulf.

It's returning data. The only problem is it's not returning the correct data.
I think it has something to do with the encoding but i cant seem to fix the problem.
Here's the file I'm trying to get.

any help appreciated.
Hi there.

I need to download files through my program from an https site.
I've done this through ftp. But can't see how it's done through https.
Can it be done? How?

Thanks in advance.
Think that is what the problem was.
Got it sorted out now though.
Thanks for the help Greg.
16 years ago
Thanks Greg. was just what I needed.

Only problem I'm getting now is with the Decryption. It Decrypts most the information fine but I see there are small sections here and there that are not decrypted properly. Is there a common reason for this that I can look for?
I'm very new to this stuff so forgive me if I seem to not know exactly what I'm doing.
Thanks again.
16 years ago
will have a look at it...
16 years ago
Hi there.

I want to use JCE for my encryption in my java program.

I was wondering if it's possible and how to use a custom string such as the hard drive serial number in my key. So that I that I can have a different key for each client that uses my program and so have my updates using a different key for each user. And so it may only be used on that machine and no other.

I haven't worked out how to get the hard drive serial number yet but I know that is a different subject all together using JNI.

I just need to know how to implement that string into the encryption. would I be able to make it part of the key, or am i going about it all wrong???

Thanks in advance.
16 years ago
Hi there.

I need to get the Hard Drive serial number. The one from the manufacturer that can't be changed. It also needs to work on any platform. I see the only way to do this is through using JNI and writing it in c or c++. From the stuff I've found. this looks like a real mission (a real lot of work).
Does any one know where I could maybe get free source code or something for this.

Any help will be appreciated.
Thanks in advance.
16 years ago
Hey guys.

I need to do encryption for my current program.
It's all new to me.
I've checked on the web and got some sort of idea, but can't find much, but I find there really is a lot to it. I was just wondering if there is a tutorial or a site or any thing where i can get the basics and get started. (from what I've seen I'll be using JCE. or maybe I'm wrong, once again, not sure)

Please help...
thanks in advance.
16 years ago