Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

professional matlabers plz solve this one program

Status
Not open for further replies.

bavamurali

Member level 1
Joined
Aug 4, 2007
Messages
41
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
india
Activity points
1,475
i=90030021002145212;
b=90030021003000000;
while(i<b)
fprintf('%f\n',i);
i=i+1;
end

I want to increment i by one and it is not going correctly solve this one
 

The answer is simple. Digits in matlab or the other software are not real !
for more information you can see the papers about round-off error.
In fact round-off error fail you problem.

Best,
 

you can test a simple code for more information,
ones(10000,1)*0.2;
sum(ans)

real answer = 2000
MATLAB answer = 2.000000000000318e+003;
 

Try i and b with number less than 2^55 should be ok.
for your case, the minimum increment may be 8.
 

This topic is interesting for me. Especially, the example of hamidrezakarami is very interesting. Cause of this error may be round-off error, the next question is that how can this problem be fixed? Can i solve tihs problem by increase sensivity or accuracy any setting?
ahmadkerl, you said that 'for your case, the minimum increment may be 8'. What is the rule for determining this?
Thanks everyone.
 

if you use
i = uint64(90030021002145212);
b = uint64(90030021003000000);

you'll might get the behaviour you expect
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top