From: Gaurav on
Hi
I am using MATLAB7.0.0.19920(R14) and am facing a problem using fixed point toolbox. The command I have used are shown:

>> b=fi('hex','0001','signed',0,'Wordlength',32,'Fractionlength',16)

b =

3.0518e-005


DataType: Fixed
Scaling: BinaryPoint
Signed: false
WordLength: 32
FractionLength: 16

RoundMode: round
OverflowMode: saturate
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: FullPrecision
MaxSumWordLength: 128
CastBeforeSum: true
>> bin(b)

ans =

00000000000000000000000000000010

Maybe I am missing out some basic understanding of how fi objects work. As I have defined a 32 bit wordlength and 16 bit fraction length shouldnt I be getting the following output?:
00000000000000000000000000000001

However there seems to be a 1-bit shift in the output attained

What i fail to understand is the rightmost bit being '0'. Please suggest some ways to correct this to the value I want, perhaps by suggesting some change in some property. or lemme know of some facts about fi objects which i am not aware of to be expecting a different output than the one obtained.
From: Ashok Charry on
Hi Gaurav,

Try this instead:

b=fi(0,'signed',0,'Wordlength',32,'Fractionlength',16,'hex','0001')

That will give you the result you are expecting.

In R14, the fi constructor expected data to be initialized first (the 0
in b = fi(0,...)) and then set to some other value by useing the
propert-value pair like (...,'hex','0001')

Hope this helps.

Thanks,

Ashok Charry
Fixed-Point Toolbox Engineer.
Mathworks

On 3/22/10 4:41 PM, Gaurav wrote:
> Hi
> I am using MATLAB7.0.0.19920(R14) and am facing a problem using fixed
> point toolbox. The command I have used are shown:
>
>>> b=fi('hex','0001','signed',0,'Wordlength',32,'Fractionlength',16)
>
> b =
>
> 3.0518e-005
>
>
> DataType: Fixed
> Scaling: BinaryPoint
> Signed: false
> WordLength: 32
> FractionLength: 16
>
> RoundMode: round
> OverflowMode: saturate
> ProductMode: FullPrecision
> MaxProductWordLength: 128
> SumMode: FullPrecision
> MaxSumWordLength: 128
> CastBeforeSum: true
>>> bin(b)
>
> ans =
>
> 00000000000000000000000000000010
>
> Maybe I am missing out some basic understanding of how fi objects work.
> As I have defined a 32 bit wordlength and 16 bit fraction length
> shouldnt I be getting the following output?:
> 00000000000000000000000000000001
>
> However there seems to be a 1-bit shift in the output attained
>
> What i fail to understand is the rightmost bit being '0'. Please suggest
> some ways to correct this to the value I want, perhaps by suggesting
> some change in some property. or lemme know of some facts about fi
> objects which i am not aware of to be expecting a different output than
> the one obtained.

From: Gaurav on
Hi

b=fi(0,'signed',0,'Wordlength',32,'Fractionlength',16,'hex','0001') does work not as well. It simply returned all zeroes upon execution.

>> b=fi(0,'signed',0,'Wordlength',32,'Fractionlength',16,'hex','0001')

b =

0


DataType: Fixed
Scaling: BinaryPoint
Signed: false
WordLength: 32
FractionLength: 16

RoundMode: round
OverflowMode: saturate
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: FullPrecision
MaxSumWordLength: 128
CastBeforeSum: true
>> bin(b)

ans =

00000000000000000000000000000000


I also tried for other values for 'hex'. For example 8000,88000 etc but still the object maintained its initialized value of 0. is there some other solution..?
Is it possible that using a newer version of MATLAB may solve this problem..?



Ashok Charry <acharry(a)mathworks.com> wrote in message <ho8mou$fsp$1(a)fred.mathworks.com>...
> Hi Gaurav,
>
> Try this instead:
>
> b=fi(0,'signed',0,'Wordlength',32,'Fractionlength',16,'hex','0001')
>
> That will give you the result you are expecting.
>
> In R14, the fi constructor expected data to be initialized first (the 0
> in b = fi(0,...)) and then set to some other value by useing the
> propert-value pair like (...,'hex','0001')
>
> Hope this helps.
>
> Thanks,
>
> Ashok Charry
> Fixed-Point Toolbox Engineer.
> Mathworks
>
> On 3/22/10 4:41 PM, Gaurav wrote:
> > Hi
> > I am using MATLAB7.0.0.19920(R14) and am facing a problem using fixed
> > point toolbox. The command I have used are shown:
> >
> >>> b=fi('hex','0001','signed',0,'Wordlength',32,'Fractionlength',16)
> >
> > b =
> >
> > 3.0518e-005
> >
> >
> > DataType: Fixed
> > Scaling: BinaryPoint
> > Signed: false
> > WordLength: 32
> > FractionLength: 16
> >
> > RoundMode: round
> > OverflowMode: saturate
> > ProductMode: FullPrecision
> > MaxProductWordLength: 128
> > SumMode: FullPrecision
> > MaxSumWordLength: 128
> > CastBeforeSum: true
> >>> bin(b)
> >
> > ans =
> >
> > 00000000000000000000000000000010
> >
> > Maybe I am missing out some basic understanding of how fi objects work.
> > As I have defined a 32 bit wordlength and 16 bit fraction length
> > shouldnt I be getting the following output?:
> > 00000000000000000000000000000001
> >
> > However there seems to be a 1-bit shift in the output attained
> >
> > What i fail to understand is the rightmost bit being '0'. Please suggest
> > some ways to correct this to the value I want, perhaps by suggesting
> > some change in some property. or lemme know of some facts about fi
> > objects which i am not aware of to be expecting a different output than
> > the one obtained.
From: Ashok Charry on
Hi Gaurav,

I'll investigate the problem you are having. But in the mean while you
may try this:

b=fi(0,'signed',0,'Wordlength',32,'Fractionlength',16);
b.hex = '0001';

Hope this works for you.

Thanks,

Charry


On 3/22/10 11:43 PM, Gaurav wrote:
> Hi
>
> b=fi(0,'signed',0,'Wordlength',32,'Fractionlength',16,'hex','0001') does
> work not as well. It simply returned all zeroes upon execution.
>
>>> b=fi(0,'signed',0,'Wordlength',32,'Fractionlength',16,'hex','0001')
>
> b =
>
> 0
>
>
> DataType: Fixed
> Scaling: BinaryPoint
> Signed: false
> WordLength: 32
> FractionLength: 16
>
> RoundMode: round
> OverflowMode: saturate
> ProductMode: FullPrecision
> MaxProductWordLength: 128
> SumMode: FullPrecision
> MaxSumWordLength: 128
> CastBeforeSum: true
>>> bin(b)
>
> ans =
>
> 00000000000000000000000000000000
>
>
> I also tried for other values for 'hex'. For example 8000,88000 etc but
> still the object maintained its initialized value of 0. is there some
> other solution..?
> Is it possible that using a newer version of MATLAB may solve this
> problem..?
>
>
>
> Ashok Charry <acharry(a)mathworks.com> wrote in message
> <ho8mou$fsp$1(a)fred.mathworks.com>...
>> Hi Gaurav,
>>
>> Try this instead:
>>
>> b=fi(0,'signed',0,'Wordlength',32,'Fractionlength',16,'hex','0001')
>>
>> That will give you the result you are expecting.
>>
>> In R14, the fi constructor expected data to be initialized first (the
>> 0 in b = fi(0,...)) and then set to some other value by useing the
>> propert-value pair like (...,'hex','0001')
>>
>> Hope this helps.
>>
>> Thanks,
>>
>> Ashok Charry
>> Fixed-Point Toolbox Engineer.
>> Mathworks
>>
>> On 3/22/10 4:41 PM, Gaurav wrote:
>> > Hi
>> > I am using MATLAB7.0.0.19920(R14) and am facing a problem using fixed
>> > point toolbox. The command I have used are shown:
>> >
>> >>> b=fi('hex','0001','signed',0,'Wordlength',32,'Fractionlength',16)
>> >
>> > b =
>> >
>> > 3.0518e-005
>> >
>> >
>> > DataType: Fixed
>> > Scaling: BinaryPoint
>> > Signed: false
>> > WordLength: 32
>> > FractionLength: 16
>> >
>> > RoundMode: round
>> > OverflowMode: saturate
>> > ProductMode: FullPrecision
>> > MaxProductWordLength: 128
>> > SumMode: FullPrecision
>> > MaxSumWordLength: 128
>> > CastBeforeSum: true
>> >>> bin(b)
>> >
>> > ans =
>> >
>> > 00000000000000000000000000000010
>> >
>> > Maybe I am missing out some basic understanding of how fi objects work.
>> > As I have defined a 32 bit wordlength and 16 bit fraction length
>> > shouldnt I be getting the following output?:
>> > 00000000000000000000000000000001
>> >
>> > However there seems to be a 1-bit shift in the output attained
>> >
>> > What i fail to understand is the rightmost bit being '0'. Please
>> suggest
>> > some ways to correct this to the value I want, perhaps by suggesting
>> > some change in some property. or lemme know of some facts about fi
>> > objects which i am not aware of to be expecting a different output than
>> > the one obtained.

From: Ashok Charry on
Hi Gaurav,
This will also work:
fi('signed',0,'WordLength',32,'FractionLength',16,'hex','0001')
And it has been verified to work in R14.
Thanks,
AShok Charry

On 3/23/10 10:18 AM, Ashok Charry wrote:
> Hi Gaurav,
>
> I'll investigate the problem you are having. But in the mean while you
> may try this:
>
> b=fi(0,'signed',0,'Wordlength',32,'Fractionlength',16);
> b.hex = '0001';
>
> Hope this works for you.
>
> Thanks,
>
> Charry
>
>
> On 3/22/10 11:43 PM, Gaurav wrote:
>> Hi
>>
>> b=fi(0,'signed',0,'Wordlength',32,'Fractionlength',16,'hex','0001') does
>> work not as well. It simply returned all zeroes upon execution.
>>
>>>> b=fi(0,'signed',0,'Wordlength',32,'Fractionlength',16,'hex','0001')
>>
>> b =
>>
>> 0
>>
>>
>> DataType: Fixed
>> Scaling: BinaryPoint
>> Signed: false
>> WordLength: 32
>> FractionLength: 16
>>
>> RoundMode: round
>> OverflowMode: saturate
>> ProductMode: FullPrecision
>> MaxProductWordLength: 128
>> SumMode: FullPrecision
>> MaxSumWordLength: 128
>> CastBeforeSum: true
>>>> bin(b)
>>
>> ans =
>>
>> 00000000000000000000000000000000
>>
>>
>> I also tried for other values for 'hex'. For example 8000,88000 etc but
>> still the object maintained its initialized value of 0. is there some
>> other solution..?
>> Is it possible that using a newer version of MATLAB may solve this
>> problem..?
>>
>>
>>
>> Ashok Charry <acharry(a)mathworks.com> wrote in message
>> <ho8mou$fsp$1(a)fred.mathworks.com>...
>>> Hi Gaurav,
>>>
>>> Try this instead:
>>>
>>> b=fi(0,'signed',0,'Wordlength',32,'Fractionlength',16,'hex','0001')
>>>
>>> That will give you the result you are expecting.
>>>
>>> In R14, the fi constructor expected data to be initialized first (the
>>> 0 in b = fi(0,...)) and then set to some other value by useing the
>>> propert-value pair like (...,'hex','0001')
>>>
>>> Hope this helps.
>>>
>>> Thanks,
>>>
>>> Ashok Charry
>>> Fixed-Point Toolbox Engineer.
>>> Mathworks
>>>
>>> On 3/22/10 4:41 PM, Gaurav wrote:
>>> > Hi
>>> > I am using MATLAB7.0.0.19920(R14) and am facing a problem using fixed
>>> > point toolbox. The command I have used are shown:
>>> >
>>> >>> b=fi('hex','0001','signed',0,'Wordlength',32,'Fractionlength',16)
>>> >
>>> > b =
>>> >
>>> > 3.0518e-005
>>> >
>>> >
>>> > DataType: Fixed
>>> > Scaling: BinaryPoint
>>> > Signed: false
>>> > WordLength: 32
>>> > FractionLength: 16
>>> >
>>> > RoundMode: round
>>> > OverflowMode: saturate
>>> > ProductMode: FullPrecision
>>> > MaxProductWordLength: 128
>>> > SumMode: FullPrecision
>>> > MaxSumWordLength: 128
>>> > CastBeforeSum: true
>>> >>> bin(b)
>>> >
>>> > ans =
>>> >
>>> > 00000000000000000000000000000010
>>> >
>>> > Maybe I am missing out some basic understanding of how fi objects
>>> work.
>>> > As I have defined a 32 bit wordlength and 16 bit fraction length
>>> > shouldnt I be getting the following output?:
>>> > 00000000000000000000000000000001
>>> >
>>> > However there seems to be a 1-bit shift in the output attained
>>> >
>>> > What i fail to understand is the rightmost bit being '0'. Please
>>> suggest
>>> > some ways to correct this to the value I want, perhaps by suggesting
>>> > some change in some property. or lemme know of some facts about fi
>>> > objects which i am not aware of to be expecting a different output
>>> than
>>> > the one obtained.
>