Hello Guest it is March 28, 2024, 04:44:35 AM

Author Topic: How to round numbers  (Read 10872 times)

0 Members and 1 Guest are viewing this topic.

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 »

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
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
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
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

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: How to round numbers
« Reply #3 on: September 08, 2008, 02:03:26 PM »
If this is a flash screen your dealing with, I can't help you.

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

My guard dog is not what you need to worry about!
Re: How to round numbers
« Reply #4 on: September 08, 2008, 02:05:08 PM »
Yes, it is a flash screen.

And thanks again.

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
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 »

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
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" )
Re: How to round numbers
« Reply #7 on: September 08, 2008, 03:28:03 PM »
This was really helpfull.
Thanks a lot.

azambuja

Offline zealous

*
  •  489 489
  • HI!
    • View Profile
    • Artsoft Solutions
Re: How to round numbers
« Reply #8 on: September 11, 2008, 07:12:16 PM »
Great  ;D

Offline Chaoticone

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

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

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