Hello Guest it is October 04, 2023, 08:10:41 PM

### Author Topic: How to round numbers  (Read 10200 times)

0 Members and 1 Guest are viewing this topic.

#### azambuja

• 10
##### How to round numbers
« on: September 08, 2008, 01:44:07 PM »
Hello friends,

How can I make this transformation:

1.3333 to 1.33

I tried to use this code:

X=Round(GetDRO(0),2)
AB=Round(X*100)/100
Call SetOEMDRO(800,AB)

but the number I gotÂ  was 1.3300.
All that I wanted was 1.33.

Thanks for any support.
« Last Edit: September 08, 2008, 01:46:16 PM by azambuja »

#### Chaoticone

• 5,624
• Precision Chaos
##### Re: How to round numbers
« Reply #1 on: September 08, 2008, 01:57:16 PM »
Can you format your dro/s to only display two decimal places and then when it pulls the value from that DRO will it only use what is seen?

Just thinking out loud.
Brett
If you could see the things I have in my head, you would be laughing too.

My guard dog is not what you need to worry about!

#### azambuja

• 10
##### Re: How to round numbers
« Reply #2 on: September 08, 2008, 02:01:29 PM »
How can I format my DRO's?
I do not know how to do it.
If you know how, hepl me.

thanks

#### Chaoticone

• 5,624
• Precision Chaos
##### Re: How to round numbers
« Reply #3 on: September 08, 2008, 02:03:26 PM »

Brett
If you could see the things I have in my head, you would be laughing too.

My guard dog is not what you need to worry about!

#### azambuja

• 10
##### Re: How to round numbers
« Reply #4 on: September 08, 2008, 02:05:08 PM »
Yes, it is a flash screen.

And thanks again.

#### zealous

• 489
• HI!
##### Re: How to round numbers
« Reply #5 on: September 08, 2008, 02:54:02 PM »
Hi,
To format a DRO use:

Example will format DRO 104

Code: [Select]
`fscommand( "DROFmt104", "%.0f")`
To format to time based:

Example will format DRO 815 and 814

Code: [Select]
`fscommand( "DROFmt815", "%D:%H:%M:%S")fscommand( "DROFmt814", "%D:%H:%M:%S")`
Thanks,
Jason Blake
« Last Edit: September 08, 2008, 03:01:34 PM by zealous »

#### zealous

• 489
• HI!
##### Re: How to round numbers
« Reply #6 on: September 08, 2008, 03:01:07 PM »
These are the formating parameters:

Days:Hours:Minutes:Seconds

Code: [Select]
`"%D:%H:%M:%S"`
(f)loating point number, (4) decimal points, (+) or -

Code: [Select]
`"+%.4f"`
integer, no decimals

Code: [Select]
`"%i"`
hex number

Code: [Select]
`"%x"`
Format to send the above:

fscommand( TYPE fmt DRO Number , ABOVE FORMAT )

Example:
fscommand ("DROFmt800" , "format" )

#### azambuja

• 10
##### Re: How to round numbers
« Reply #7 on: September 08, 2008, 03:28:03 PM »
Thanks a lot.

azambuja

#### zealous

• 489
• HI!
##### Re: How to round numbers
« Reply #8 on: September 11, 2008, 07:12:16 PM »
Great

#### Chaoticone

• 5,624
• Precision Chaos
##### Re: How to round numbers
« Reply #9 on: September 11, 2008, 07:13:35 PM »
Thanks for helping Jason.

Brett
If you could see the things I have in my head, you would be laughing too.

My guard dog is not what you need to worry about!